2012-09-13 33 views
1

我開發了插件ascensor.js(http://kirkas.ch/ascensor/) 完全重寫它(whitout scrollto插件)後,我遇到了一些調整大小功能的錯誤。調整大小元素和動畫的scrolltop/scrollleft反彈的bug

當你這樣做,有一定的反彈效應(鉻),你可以看到其他樓層的一小部分,我知道,每個瀏覽器都有不同的大小調整的效果,但我不知道是否有一種方法來解決它。

調整效果: 的Chrome/Safari/Firefox中:小幅反彈,看看其他地板 歌劇:沒有調整影響,直到點擊了

這裏全插件:http://kirkas.ch/ascensor/js/jquery.ascensor.js

這裏關於調整大小的部分fonction:

function resizeFloor(){ 
    var WW=$(window).width(); 
    var WH=$(window).height() 

    if(params.Direction=='y'){$(node).stop().animate({scrollTop:(floor-1)*WH},1);} 
    if(params.Direction=='x'){$(node).stop().animate({scrollLeft:(floor-1)*WW},1);} 
    if(params.Direction=='chocolate'){ 
     var target = AscensorMap[StageOn-1].split('|'); 
     $(node).stop().animate({ 
     scrollLeft:(target[1]-1)*WW, 
     scrollTop:(target[0]-1)*WH 
     },1); 
    } 


    $(node).height(WH).width(WW).children(params.ChildType).each(function(){ 
     $(this).height(WH).width(WW); 
    }); 

    if(params.Direction=='x'){ 
     $(node).children().css('position','absolute'); 
     $(node).children().each(function(index){$(this).css('left',index*WW);}) 
    } 

    if(params.Direction=='chocolate'){ 
     $(node).children(params.ChildType).each(function(index){ 
      var CoordName = AscensorMap[index].split('|'); 
      $(this).css({'position':'absolute', 'left':(CoordName[1]-1)*WW, 'top':(CoordName[0]-1)*WH}); 
     }); 
    } 
} 

而且我在JS的發展相當新的,所以如果你有關於對系統的語法或批評任何建議,我是完全開放的。

感謝

回答

1

我完成我自己找,而不是

$(node).stop().animate({ 
    scrollLeft:(target[1]-1)*WW, 
    scrollTop:(target[0]-1)*WH 
},1); 

我應該使用

$(node).stop().scrollTop((target[0]-1)*WH).scrollLeft((target[1]-1)*WW); 
+0

THX您啓發了我與我的問題,THX :) –