be-fe / iSlider

Smooth mobile touch slider for Mobile WebApp, HTML5 App, Hybrid App
http://be-fe.github.io/iSlider/
MIT License
1.66k stars 448 forks source link

请问有没有什么办法可以知道当前页是整个动画里的第几页 #158

Closed danceash closed 9 years ago

danceash commented 9 years ago

我现在在用iSlider做一个展示的电子杂志,需要对其中特定页面加一些动画特效,所以想在切到某一页时,知道其在动画中是第几也,也就是页码数i,再配合islider.slideTo(i);即可切到这一页,请问有什么方法吗?

danceash commented 9 years ago

另外,还遇到一个问题,就是我在页面内加上了连接,连接到http://www.baidu.com,再返回的时候,有链接的页面的右侧页面为空,是没有办法往左滑动的,当向右滑动再返回有链接页面的时候,其右侧页面又出现了,不清楚是什么问题导致的,

xieyu33333 commented 9 years ago

你好, 使用islider.slideIndex就可以得到索引值

danceash commented 9 years ago

你好,非常感谢,这个我用了一下,没有问题了。但还有另一种情况,就是页面跳转再返回后,使用islider.slideTo(i);跳转到有链接的那张图片后,会出现右侧没有图片的情况。具体情况是 onslidechange:function(){ history.pushState(null,'New Page', '#index='+islider.sliderIndex); }给每个页面添加唯一的url,在当前页面添加链接,比如连接到http://www.baidu.com,再回退,使用islider.slideTo(i);跳转到链接页,会出现右侧没有图片,左侧有,滑动到左侧页面,再返回,就可以看到链接页右侧的页面了,希望您能帮我看一下是什么原因导致的,谢谢!

xieyu33333 commented 9 years ago

islider会生成3个<li>容器,你检查一下右侧对应的li内是否有内容,如果有,检查一下是否被置为了visibility:hidden。

danceash commented 9 years ago

嗯,我看一下,右侧对应的li中visibility:visible的,但是是一个空的li,但是右侧的li中应该是有数据的,

xieyu33333 commented 9 years ago

那你需要打断点看一下下面这段代码,看看是否正确执行 if ( Math.abs(n) > 1) { this._renderItem(els[0], idx - 1); this._renderItem(els[2], idx + 1); } else if (Math.abs(n) === 1) { this._renderItem(sEle, idx + n); }

danceash commented 9 years ago

正常情况下都是执行else语句,但是从连接返回来,使用islider.slideTo(i)之后,执行的if语句,是这里的问题吗?

xieyu33333 commented 9 years ago

有可能,感觉问题描述的不是特别清楚,如果有可以访问的地址的话可以看一下。

danceash commented 9 years ago

http://statics.witmob.com/two/index.html,这是链接,东西做的很粗糙,请不要介意,在第三页有一个文字链接,aaaaaaa,点击之后会跳转到baidu首页,然后再点击返回,返回到第3页,就会看不到右侧的页面了,通过查看元素也可以发现,第一个li里面是空的,没有数据

wtcsy commented 9 years ago

lz你好 正在学习这个效果 请教个问题 如果不是当前正中间的图片 他的translateZ是怎么算出来的,让图片正好在容器的边缘???

danceash commented 9 years ago

朋友你好,关于iSlider里面详细的逻辑,我还没有仔细研究,目前处于刚会用的阶段,你的这个问题我也不清楚,还是请作者来回答吧,抱歉了

xieyu33333 commented 9 years ago

你应该先获取location里的index值,然后再new iSlider,让initIndex等于index,另外建议你使用新版本,你使用的这个版本应该没有加入initIndex这个参数

danceash commented 9 years ago

作者说的对,我的iSlider确实不是最新版本,因为这不是我开始的一个项目,所以没有考虑到这一点,给作者添麻烦了,很抱歉。按照作者上面给出的方法,问题完美解决,非常感谢作者,帮了我很大的忙,谢谢!