【问题标题】:Code for how to stop just on 3 image如何仅在 3 个图像上停止的代码
【发布时间】:2018-08-27 00:12:09
【问题描述】:

大家好,我遵循本教程Roulette Demo,但我想确定如何仅在 3 张图片上停止。

我尝试使用此代码:

var defaultSettings = {
            maxPlayCount : null, // x >= 0 or null
            speed : 10, // x > 0
            stopImageNumber : 2,  // x >= 0 or null ors -1
            rollCount : 3, // x >= 0
            duration : 3, //(x second)
            stopCallback : function() {
            },
            startCallback : function() {
            },
            slowDownCallback : function() {
            }
        }

我将 stopImageNumber 更改为 stopImageNumber: 2,3stopImageNumber 2 || 3。但它不起作用..

有人知道怎么解决吗?

【问题讨论】:

  • 嗨! SO 的工作方式,您的整个问题(包括任何必要的代码)必须in 您的问题,而不仅仅是链接。两个原因:人们不应该去场外帮助你;和链接腐烂,使问题及其答案对未来的人们毫无用处。请在问题中输入minimal reproducible example in。更多:How do I ask a good question?
  • 使用tour 是件好事,尽管您已经成为会员两年多了。你会得到一个徽章。 :-)
  • 我很抱歉先生,我是新人。我会更好地询问..谢谢你的信息:)
  • 别担心!但请务必使用“编辑”链接来解决问题。 :-)
  • 完成先生 :) 先生,您能帮我解决我的问题吗?

标签: javascript spinner


【解决方案1】:

直接看方法,好像只接受一个整数值,null,或者-1。

// x >= 0 or null or -1

https://github.com/akira-kuriyama/roulette.js/blob/master/roulette.js#L6

它的使用方法如下:

p.stopImageNumber = $.isNumeric(defaultProperty.originalStopImageNumber) && Number(defaultProperty.originalStopImageNumber) >= 0 ? Number(defaultProperty.originalStopImageNumber) : Math.floor(Math.random() * p.imageCount);

https://github.com/akira-kuriyama/roulette.js/blob/master/roulette.js#L142

【讨论】:

  • 谢谢你的帮助先生.. 但我的意思是,我只想停在 3 图像.. 你能阻止我吗?
  • 你做了什么代码?我建议设置一个 jsfiddle
  • 不,先生,我还在尝试,但它没用。我是新手,请联系我jsfiddle.net/drxwj30k
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-07
  • 2015-05-27
  • 2021-12-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多