我創建了一個帶有jquery.mousewheel和scrollTo的系統,每次移動我的鼠標滾輪時都會滾動800像素。瀏覽與此類似網站:http://beoplay.com/Products/BeoplayA8#sound-experience將URL附加到jquery函數
我當前的代碼如下所示:
var position = 1;
var rotation= true;
var ezin= 'easeInOutExpo';
if (position==1){
$.scrollTo('0px', 100, { axis:'y',easing: ezin });
$('.variable').text("1");
}
function DEL1AL2(){
rotation= false;
$('.variable').text("2");
$.scrollTo('800px', 800, { axis:'y',easing: ezin, onAfter: function() {rotation= true; position=2;} });
}
function DEL2AL1(){
rotation= false;
$('.variable').text("1");
$.scrollTo('0px', 800, { axis:'y',easing: ezin, onAfter: function() {rotation= true; position=1;} });
}
function DEL2AL3(){
rotation= false;
$('.variable').text("3");
$.scrollTo('1600px', 800, { axis:'y',easing: ezin, onAfter: function() {rotation= true; position=3;} });
}
function DEL3AL2(){
rotation= false;
$('.variable').text("2");
$.scrollTo('800px', 800, { axis:'y',easing: ezin, onAfter: function() {rotation= true; position=2} });
;
}
$(document).mousewheel(function(event, delta) {
if (delta > 0 && rotation==true){
if(position==2){
DEL2AL1();
};
if(position==3){
DEL3AL2();
};
}
else if (delta < 0 && rotation==true){
if(position==1){
DEL1AL2();
};
if(position==2){
DEL2AL3();
};
};
event.preventDefault();
});});
該系統具有數字變量連接,所以,當你在位置1和向下滾動下來,功能春聯800像素,並將位置變量更改爲2.
如何添加深層鏈接(我認爲這是術語),因此當位置爲2時,URL反映它(www.myexample.com/# 2例如),所以鏈接實際上把你帶到第二個位置?
我試圖這樣做的唯一原因是因爲我想在頁面的不同位置有自己的Facebook喜歡(投資組合項目),如果深層鏈接是不必要的,有更好的方法來完成,我」所有的耳朵。另外,如果您在我當前的代碼中看到任何錯誤,請告訴我,我正在慢慢地學習,任何可以拋光的東西都是值得歡迎的。
在此先感謝。
那麼基本上,錨點滾動? – Flater
不確定,但我會考慮這一點。作爲新手意味着有時我找不到教程,因爲我不知道這些條款。 – Dlacrem