1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- function scroll() {
- if(window.pageYOffset !== null){
- return {
- top: window.pageYOffset,
- left: window.pageXOffset
- }
- }else if(document.compatMode === "CSS1Compat"){
- return {
- top: document.documentElement.scrollTop,
- left: document.documentElement.scrollLeft
- }
- }
- return {
- top: document.body.scrollTop,
- left: document.body.scrollLeft
- }
- }
- function $(id) {
- return typeof id === "string" ? document.getElementById(id) : null;
- }
- function client() {
- if(window.innerWidth){
- return {
- width: window.innerWidth,
- height: window.innerHeight
- }
- }else if(document.compatMode === "CSS1Compat"){
- return {
- width: document.documentElement.clientWidth,
- height: document.documentElement.clientHeight
- }
- }
- return {
- width: document.body.clientWidth,
- height: document.body.clientHeight
- }
- }
- function constant(obj, target, speed) {
-
- clearInterval(obj.timer);
-
- var dir = obj.offsetLeft < target ? speed : -speed;
-
- obj.timer = setInterval(function () {
- obj.style.left = obj.offsetLeft + dir + "px";
- if(Math.abs(target - obj.offsetLeft) < Math.abs(dir)){
- clearInterval(obj.timer);
- obj.style.left = target + "px";
- console.log(obj.offsetLeft, target);
- }
- }, 20);
- }
|