https://github.com/cy0707/about_javascript/tree/master/cusScrollBar 這個是完整的代碼。
還有根據這問課程的總結 https://github.com/cy0707/about_javascript/issues/29
還有瀏覽器的尺寸的文章總結 https://github.com/cy0707/about_javascript/issues/17
希望大家一起交流
還有根據這問課程的總結 https://github.com/cy0707/about_javascript/issues/29
還有瀏覽器的尺寸的文章總結 https://github.com/cy0707/about_javascript/issues/17
希望大家一起交流
2016-11-18
.scroll-wrap .scroll-cont{
width:100%;
height:100%;
overflow: hidden;
padding:0 15px;
}
加一個height和overflow 效果調試出來,為了這2行代碼,調試了一個多小時,希望不要有人跟我犯一樣的錯誤
width:100%;
height:100%;
overflow: hidden;
padding:0 15px;
}
加一個height和overflow 效果調試出來,為了這2行代碼,調試了一個多小時,希望不要有人跟我犯一樣的錯誤
2016-11-18
對于內容不夠的時候,那段js。其實有時候你不知有多少內容,加起來很麻煩的。可以通過CSS設置.scroll-ol {
min-height: 100%;
}
這樣不需要矯正元素和那段js
min-height: 100%;
}
這樣不需要矯正元素和那段js
2016-11-18
getMaxScrollPosition: function() {
var self = this;
console.log(self.$cont.height()); //300
console.log(self.$cont[0].scrollHeight); //300
return Math.max(self.$cont.height(), self.$cont[0].scrollHeight) - self.$cont.height();
},
var self = this;
console.log(self.$cont.height()); //300
console.log(self.$cont[0].scrollHeight); //300
return Math.max(self.$cont.height(), self.$cont[0].scrollHeight) - self.$cont.height();
},
2016-11-18
dragContBarRate = self.getMaxScrollPosition()/self.getMaxSliderPosition();這個結果為0
2016-11-18
簡單分析下老師寫這些的原理。
function CusScrollBar(options){} 和CusScrollBar.prototype._init=function() 這個是采用了面向對象中的(組合構造函數和原型模式)的方法;
通過function CusScrollBar(options){} 傳參讓每個實例有自己的屬性;CusScrollBar.prototype._init 是原型,來確保所有實例都共享的方法
function CusScrollBar(options){} 和CusScrollBar.prototype._init=function() 這個是采用了面向對象中的(組合構造函數和原型模式)的方法;
通過function CusScrollBar(options){} 傳參讓每個實例有自己的屬性;CusScrollBar.prototype._init 是原型,來確保所有實例都共享的方法
2016-11-17