Sfoglia il codice sorgente

图片流动小调整

zachary 4 anni fa
parent
commit
c37341134a
7 ha cambiato i file con 477 aggiunte e 125 eliminazioni
  1. 15 10
      exhibition.css
  2. 4 0
      index.css
  3. 33 14
      index.html
  4. 285 0
      public/ScrollPic.js
  5. 2 0
      public/jquery.min.js
  6. 43 101
      script/flow.js
  7. 95 0
      scrollPic.css

+ 15 - 10
exhibition.css

@@ -23,9 +23,9 @@
 .row1{
 .row1{
     position:absolute;
     position:absolute;
     top:0;
     top:0;
-    left:9.3rem;
+    left:11rem;
     overflow: hidden;
     overflow: hidden;
-    width:100%;
+    width:87.3rem;
     height:15rem;
     height:15rem;
     /* background-color: lavenderblush; */
     /* background-color: lavenderblush; */
 }
 }
@@ -34,23 +34,28 @@
 .row2{
 .row2{
     position:absolute;
     position:absolute;
     top:18.8rem;
     top:18.8rem;
-    right:7.1rem;
+    right:11rem;
     overflow: hidden;
     overflow: hidden;
-    width:100%;
+    width:87.3rem;
     height:15rem;
     height:15rem;
     /* background-color: lavenderblush; */
     /* background-color: lavenderblush; */
 }
 }
 
 
+.above {
+    left: 0;
+}
+
+.below {
+    right: 0;
+}
+
+
+
 
 
 .treasures{
 .treasures{
     position:absolute;
     position:absolute;
     top:0;
     top:0;
     height:15rem;
     height:15rem;
-    /* display: flex;
-    justify-content: space-between; */
-    /* -webkit-animation: 3s linear 1s infinite running slidein;
-        -ms-animation: 3s linear 1s infinite running slidein;
-            animation: 3s linear 1s infinite running slidein; */
 }
 }
 
 
 
 
@@ -267,7 +272,7 @@ div.index_on{
     background-color: orange;
     background-color: orange;
 }
 }
 
 
-.disappear{
+div.disappear{
     display: none;
     display: none;
 }
 }
 
 

+ 4 - 0
index.css

@@ -296,3 +296,7 @@ img.img4{
     width:12.3rem;
     width:12.3rem;
     height:2.91rem;
     height:2.91rem;
 }
 }
+
+img.img4:hover{
+    box-shadow: 2px 2px 5px;
+}

File diff suppressed because it is too large
+ 33 - 14
index.html


+ 285 - 0
public/ScrollPic.js

@@ -0,0 +1,285 @@
+var sina = {
+    $: function (objName) {
+        if (document.getElementById) {
+            return eval('document.getElementById("' + objName + '")')
+        } else {
+            return eval('document.all.' + objName)
+        }
+    }, isIE: navigator.appVersion.indexOf("MSIE") != -1 ? true : false, addEvent: function (l, i, I) {
+        if (l.attachEvent) {
+            l.attachEvent("on" + i, I)
+        } else {
+            l.addEventListener(i, I, false)
+        }
+    }, delEvent: function (l, i, I) {
+        if (l.detachEvent) {
+            l.detachEvent("on" + i, I)
+        } else {
+            l.removeEventListener(i, I, false)
+        }
+    }, readCookie: function (O) {
+        var o = "", l = O + "=";
+        if (document.cookie.length > 0) {
+            var i = document.cookie.indexOf(l);
+            if (i != -1) {
+                i += l.length;
+                var I = document.cookie.indexOf(";", i);
+                if (I == -1) I = document.cookie.length;
+                o = unescape(document.cookie.substring(i, I))
+            }
+        }
+        ;
+        return o
+    }, writeCookie: function (i, l, o, c) {
+        var O = "", I = "";
+        if (o != null) {
+            O = new Date((new Date).getTime() + o * 3600000);
+            O = "; expires=" + O.toGMTString()
+        }
+        ;
+        if (c != null) {
+            I = ";domain=" + c
+        }
+        ;document.cookie = i + "=" + escape(l) + O + I
+    }, readStyle: function (I, l) {
+        if (I.style[l]) {
+            return I.style[l]
+        } else if (I.currentStyle) {
+            return I.currentStyle[l]
+        } else if (document.defaultView && document.defaultView.getComputedStyle) {
+            var i = document.defaultView.getComputedStyle(I, null);
+            return i.getPropertyValue(l)
+        } else {
+            return null
+        }
+    }
+};
+
+function ScrollPic(scrollContId, arrLeftId, arrRightId, dotListId) {
+    this.scrollContId = scrollContId;
+    this.arrLeftId = arrLeftId;
+    this.arrRightId = arrRightId;
+    this.dotListId = dotListId;
+    this.dotClassName = "dotItem";
+    this.dotOnClassName = "dotItemOn";
+    this.dotObjArr = [];
+    this.pageWidth = 0;
+    this.frameWidth = 0;
+    this.speed = 10;
+    this.space = 10;
+    this.pageIndex = 0;
+    this.autoPlay = true;
+    this.autoPlayTime = 5;
+    var _autoTimeObj, _scrollTimeObj, _state = "ready";
+    this.stripDiv = document.createElement("DIV");
+    this.listDiv01 = document.createElement("DIV");
+    this.listDiv02 = document.createElement("DIV");
+    if (!ScrollPic.childs) {
+        ScrollPic.childs = []
+    }
+    ;this.ID = ScrollPic.childs.length;
+    ScrollPic.childs.push(this);
+    this.initialize = function () {
+        if (!this.scrollContId) {
+            throw new Error("scrollContId.");
+            return
+        }
+        ;this.scrollContDiv = sina.$(this.scrollContId);
+        if (!this.scrollContDiv) {
+            throw new Error("scrollContId.(scrollContId = \"" + this.scrollContId + "\")");
+            return
+        }
+        ;this.scrollContDiv.style.width = this.frameWidth + "px";
+        this.scrollContDiv.style.overflow = "hidden";
+        this.listDiv01.innerHTML = this.listDiv02.innerHTML = this.scrollContDiv.innerHTML;
+        this.scrollContDiv.innerHTML = "";
+        this.scrollContDiv.appendChild(this.stripDiv);
+        this.stripDiv.appendChild(this.listDiv01);
+        this.stripDiv.appendChild(this.listDiv02);
+        this.stripDiv.style.overflow = "hidden";
+        this.stripDiv.style.zoom = "1";
+        this.stripDiv.style.width = "32766px";
+        this.listDiv01.style.cssFloat = "left";
+        this.listDiv02.style.cssFloat = "left";
+        sina.addEvent(this.scrollContDiv, "mouseover", Function("ScrollPic.childs[" + this.ID + "].stop()"));
+        sina.addEvent(this.scrollContDiv, "mouseout", Function("ScrollPic.childs[" + this.ID + "].play()"));
+        if (this.arrLeftId) {
+            this.arrLeftObj = sina.$(this.arrLeftId);
+            if (this.arrLeftObj) {
+                sina.addEvent(this.arrLeftObj, "mousedown", Function("ScrollPic.childs[" + this.ID + "].rightMouseDown()"));
+                sina.addEvent(this.arrLeftObj, "mouseup", Function("ScrollPic.childs[" + this.ID + "].rightEnd()"));
+                sina.addEvent(this.arrLeftObj, "mouseout", Function("ScrollPic.childs[" + this.ID + "].rightEnd()"))
+            }
+        }
+        ;
+        if (this.arrRightId) {
+            this.arrRightObj = sina.$(this.arrRightId);
+            if (this.arrRightObj) {
+                sina.addEvent(this.arrRightObj, "mousedown", Function("ScrollPic.childs[" + this.ID + "].leftMouseDown()"));
+                sina.addEvent(this.arrRightObj, "mouseup", Function("ScrollPic.childs[" + this.ID + "].leftEnd()"));
+                sina.addEvent(this.arrRightObj, "mouseout", Function("ScrollPic.childs[" + this.ID + "].leftEnd()"))
+            }
+        }
+        ;
+        if (this.dotListId) {
+            this.dotListObj = sina.$(this.dotListId);
+            if (this.dotListObj) {
+                var pages = Math.round(this.listDiv01.offsetWidth / this.frameWidth + 0.4), i, tempObj;
+                for (i = 0; i < pages; i++) {
+                    tempObj = document.createElement("span");
+                    this.dotListObj.appendChild(tempObj);
+                    this.dotObjArr.push(tempObj);
+                    if (i == this.pageIndex) {
+                        tempObj.className = this.dotClassName
+                    } else {
+                        tempObj.className = this.dotOnClassName
+                    }
+                    ;tempObj.title = "" + (i + 1) + "ҳ";
+                    sina.addEvent(tempObj, "click", Function("ScrollPic.childs[" + this.ID + "].pageTo(" + i + ")"))
+                }
+            }
+        }
+        ;
+        if (this.autoPlay) {
+            this.play();
+            console.log("play");
+        }
+    };
+    this.leftMouseDown = function () {
+        if (_state != "ready") {
+            return
+        }
+        ;_state = "floating";
+        _scrollTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].moveLeft()", this.speed)
+    };
+    this.rightMouseDown = function () {
+        if (_state != "ready") {
+            return
+        }
+        ;_state = "floating";
+        _scrollTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].moveRight()", this.speed)
+    };
+    this.moveLeft = function () {
+        if (this.scrollContDiv.scrollLeft + this.space >= this.listDiv01.scrollWidth) {
+            this.scrollContDiv.scrollLeft = this.scrollContDiv.scrollLeft + this.space - this.listDiv01.scrollWidth
+        } else {
+            this.scrollContDiv.scrollLeft += this.space
+        }
+        ;this.accountPageIndex()
+    };
+    this.moveRight = function () {
+        if (this.scrollContDiv.scrollLeft - this.space <= 0) {
+            this.scrollContDiv.scrollLeft = this.listDiv01.scrollWidth + this.scrollContDiv.scrollLeft - this.space
+        } else {
+            this.scrollContDiv.scrollLeft -= this.space
+        }
+        ;this.accountPageIndex()
+    };
+    this.leftEnd = function () {
+        if (_state != "floating") {
+            return
+        }
+        ;_state = "stoping";
+        clearInterval(_scrollTimeObj);
+        var fill = this.pageWidth - this.scrollContDiv.scrollLeft % this.pageWidth;
+        this.move(fill)
+    };
+    this.rightEnd = function () {
+        if (_state != "floating") {
+            return
+        }
+        ;_state = "stoping";
+        clearInterval(_scrollTimeObj);
+        var fill = -this.scrollContDiv.scrollLeft % this.pageWidth;
+        this.move(fill)
+    };
+    this.move = function (num, quick) {
+        var thisMove = num / 5;
+        console.log(thisMove);
+        if (!quick) {
+            if (thisMove > this.space) {
+                thisMove = this.space;
+            }
+            ;
+            if (thisMove < -this.space) {
+                thisMove = -this.space;
+            }
+        }
+        ;
+        if (Math.abs(thisMove) < 1 && thisMove != 0) {
+            thisMove = thisMove >= 0 ? 1 : -1
+        } else {
+            thisMove = Math.round(thisMove)
+        }
+        ;var temp = this.scrollContDiv.scrollLeft + thisMove;
+        if (thisMove > 0) {
+            if (this.scrollContDiv.scrollLeft + thisMove >= this.listDiv01.scrollWidth) {
+                this.scrollContDiv.scrollLeft = this.scrollContDiv.scrollLeft + thisMove - this.listDiv01.scrollWidth
+            } else {
+                this.scrollContDiv.scrollLeft += thisMove
+            }
+        } else {
+            if (this.scrollContDiv.scrollLeft - thisMove <= 0) {
+                console.log("<");
+                this.scrollContDiv.scrollLeft = this.listDiv01.scrollWidth + this.scrollContDiv.scrollLeft - thisMove
+            } else {
+                
+                this.scrollContDiv.scrollLeft += thisMove;
+            }
+        }
+        ;num -= thisMove;
+
+        if (Math.abs(num) == 0) {
+            _state = "ready";
+            if (this.autoPlay) {
+                this.play()
+            }
+            ;this.accountPageIndex();
+            return
+        } else {
+            this.accountPageIndex();
+            setTimeout("ScrollPic.childs[" + this.ID + "].move(" + num + "," + quick + ")", this.speed)
+        }
+    };
+    this.next = function () {
+        // console.log("inNext");
+        if (_state != "ready") {
+            return
+        }
+        ;_state = "stoping";
+        this.move(this.pageWidth, true)
+    };
+    this.play = function () {
+        // console.log("inPlay");
+        if (!this.autoPlay) {
+            return
+        }
+        ;clearInterval(_autoTimeObj);
+        _autoTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].next()", this.autoPlayTime * 1000)
+    };
+    this.stop = function () {
+        clearInterval(_autoTimeObj)
+    };
+    this.pageTo = function (num) {
+        if (_state != "ready") {
+            return
+        }
+        ;_state = "stoping";
+        var fill = num * this.frameWidth - this.scrollContDiv.scrollLeft;
+        this.move(fill, true)
+    };
+    this.accountPageIndex = function () {
+        this.pageIndex = Math.round(this.scrollContDiv.scrollLeft / this.frameWidth);
+        if (this.pageIndex > Math.round(this.listDiv01.offsetWidth / this.frameWidth + 0.4) - 1) {
+            this.pageIndex = 0
+        }
+        ;var i;
+        for (i = 0; i < this.dotObjArr.length; i++) {
+            if (i == this.pageIndex) {
+                this.dotObjArr[i].className = this.dotClassName
+            } else {
+                this.dotObjArr[i].className = this.dotOnClassName
+            }
+        }
+    }
+};

File diff suppressed because it is too large
+ 2 - 0
public/jquery.min.js


+ 43 - 101
script/flow.js

@@ -1,120 +1,62 @@
-let row1s = [].slice.call(document.querySelectorAll(".row1")),
-    row1Length = row1s.length,
-    row2s = [].slice.call(document.querySelectorAll(".row2")),
-    row2sLength = row2s.length;
-    // aboveInisialLeft = row1.offsetLeft,
-    
-    // belowInisialLeft = row2.offsetLeft;
-
-const LEFT = 1,RIGHT = 2;
-
-for(let i = 0; i < row1Length; i++){
+let aboveDivs = [].slice.call(document.querySelectorAll(".above")),
+    aboveDivsLength = aboveDivs.length,
+    belowDivs = [].slice.call(document.querySelectorAll(".below")),
+    belowDivsLength = belowDivs.length;
+const aboveIntervalId = [],belowIntervalId = [];
+const LEFT = 1,RIGHT = 2,VIEWBOXS = 6;
+let viewWidth = aboveDivs[0].offsetWidth * VIEWBOXS;
+let row1s = [].slice.call(document.getElementsByClassName("row1")),
+    row2s = [].slice.call(document.getElementsByClassName("row2"));
+row1s.forEach(element => {
+    element.style.width = viewWidth;
+});
+
+for(let i = 0; i < aboveDivsLength; i++){
     console.log(i);
     console.log(i);
-    let aboveIntervalId,belowIntervalId,
-        aboveInisialLeft = row1s[i].offsetLeft,
-        belowInisialLeft = row2s[i].offsetLeft;
+    let aboveInisialLeft = aboveDivs[i].offsetLeft,
+        belowInisialLeft = belowDivs[i].offsetLeft;
 
 
-        animate(row1s[i],1,1);
-        animate(row2s[i],2,1);
-}
+        animate(aboveDivs[i],LEFT,1);
+        animate(belowDivs[i],RIGHT,1);
 
 
+}
 /**
 /**
  * 
  * 
- * @param {HTMLElement} row 
+ * @param {HTMLElement} div 
  * @param {String} direction 
  * @param {String} direction 
  * @param {integer} velocity 
  * @param {integer} velocity 
  */
  */
-function animate(row,direction,velocity){
-    let treasureArray =  row.querySelectorAll(".treasure"),
+function animate(div,direction,velocity){
+    let treasureArray =  div.querySelectorAll(".treasure"),
         tLength = treasureArray.length,
         tLength = treasureArray.length,
-        boxWidth = row.querySelector(".treasure").offsetWidth,
-        allBoxsWidth = boxWidth * tLength  - 0.9 *innerWidth,
-        inisialLeft = row.offsetLeft;
+        boxWidth = div.querySelector(".treasure").offsetWidth,
+        allBoxsWidth = boxWidth * (tLength - 6),
+        inisialLeft;
         // console.log("tLength",tLength,"inisialLeft",inisialLeft,"allBoxsWidth",allBoxsWidth);
         // console.log("tLength",tLength,"inisialLeft",inisialLeft,"allBoxsWidth",allBoxsWidth);
     if(direction == LEFT){
     if(direction == LEFT){
-        aboveIntervalId = setInterval(()=>{
-            row.style.left = (row.offsetLeft - velocity) + 'px';
-            // console.log("LEFT",row.style.left);
-            if(row.offsetLeft < -1 * (allBoxsWidth)){
-                row.style.left = inisialLeft + 'px';
+        inisialLeft = div.offsetLeft;
+        console.log(inisialLeft);
+        let tempIntervalId = setInterval(()=>{
+            div.style.left = (div.offsetLeft - velocity) + 'px';
+            // console.log("LEFT",div.style.left);
+            if(div.offsetLeft < -1 * (allBoxsWidth)){
+                div.style.left = inisialLeft + 'px';
             }
             }
-        },16);
+        },40);
+        aboveIntervalId.push(tempIntervalId);
         
         
     }else if(direction == RIGHT){
     }else if(direction == RIGHT){
-        belowIntervalId = setInterval(()=>{
-            row.style.left = (row.offsetLeft + velocity) + 'px';
-            // console.log("RIGHT",row.style.left);
-            if(row.offsetLeft  > allBoxsWidth){
-                row.style.left = inisialLeft  + 'px';
+        inisialLeft = -allBoxsWidth;
+        console.log(inisialLeft);
+        let tempIntervalId  = setInterval(()=>{
+            div.style.left = (div.offsetLeft + velocity) + 'px';
+            // console.log("RIGHT",div.style.left);
+            if(div.offsetLeft  >= 0){
+                div.style.left = inisialLeft  + 'px';
             }
             }
-        },16); 
-
+        },40); 
+        belowIntervalId.push(tempIntervalId);
     }
     }
 }
 }
 
 
 
 
-row1.onmouseover = ()=>{
-    clearInterval(aboveIntervalId);    
-}
-row1.onmouseleave = ()=>{
-    animate(row1,LEFT,1);
-};
-
-row2.onmouseover = ()=>{
-    clearInterval(belowIntervalId);    
-}
-row2.onmouseleave = ()=>{
-    animate(row2,RIGHT,1);
-};
-
-
-// let museums = document.querySelector(".museum");
-
-
-
-
-
-
-// let iframe = document.querySelector("#visiting");
-// let row1TreasureNodes = museum.querySelectorAll(".treasure");
-// let name;
-//TODO:给底部博物馆名添加监听器
-
-// let row1Treasures = [].slice.call(row1TreasureNodes);
-/*
-for(let i = 0; i < row1TreasureNodes.length;i++){
-    row1TreasureNodes[i].addEventListener("click",(e,i)=>{
-        // iframe.contentWindow.location.href = urls[i];
-        iframe.classList.remove("disappear");
-    });
-}
-*/
-
-// function switchMuseum(){
-    
-//     let museumButtons = document.querySelectorAll(".museumname"),
-//         mbLength = museumButtons.length,
-//         museums = document.querySelector(".museum"),
-//         mLength = museums.length;
-//     for(let i = 0; i < museumButtons; i++){
-//         museumButtons[i].addEventListener("click",(e,index = i)=>{
-//             let target = e.target;
-//             museums[i].classList.add("appear");
-//             console.log("switch");
-//         })
-//     }
-
-// }
-// switchMuseum();
-
-let museumButtons = [].slice.call(document.querySelectorAll(".museumname")),
-    mbLength = museumButtons.length,
-    museums = [].slice.call(document.querySelectorAll(".museum")),
-    mLength = museums.length;
-for(let i = 0; i < museumButtons; i++){
-    museumButtons[i].addEventListener("click",(e,index = i)=>{
-        let target = e.target;
-        museums[index].classList.add("appear");
-        console.log("switch",i);
-    });
-}

+ 95 - 0
scrollPic.css

@@ -0,0 +1,95 @@
+.picCenter {
+    width: 888px;
+    margin: 15px auto;
+}
+
+.xinxiIcon {
+    margin:0 0 -20px auto;
+}
+
+.xinxiIcon img {
+    width: 100%;
+    height: auto;
+    object-fit: cover;
+}
+
+.photo_img img {
+    box-sizing: border-box;transition:all .7s ease 0s;
+    width:19rem;
+}
+.photo_img img:hover {box-sizing: border-box;border: 1px solid #023246;
+  box-shadow: 1px 0px 15px -3px rgba(0,0,0,0.53);
+-webkit-box-shadow: 1px 0px 15px -3px rgba(0,0,0,0.53);
+-moz-box-shadow: 1px 0px 15px -3px rgba(0,0,0,0.53);
+}
+
+.photo_nr {
+    display: flex;
+    align-items: center;
+    width: 88.2rem;
+    margin: 15px auto;
+}
+
+.informationText {
+    width: 888px;
+    margin: 15px auto;
+    text-align: center;
+}
+
+.informationText span {
+
+    background: #ffffff;
+    color: #1C1F86;
+}
+
+ul {
+    list-style: none;
+    padding: 0;
+    margin: 0;
+}
+
+.photo_nr ul li {
+    float: left;
+    margin: 0 35px;
+    line-height: 30px;
+    text-align: center;
+}
+
+/* .photo_nr p {
+    padding: 0;
+    margin: 0;
+} */
+
+
+#LeftArr {
+    background: url(img/e_left.png) no-repeat;
+    width: 40px;
+    height: 40px;
+    margin-left: -15px;
+    text-decoration: none;
+    color: #323232;
+}
+
+#RightArr {
+    background: url(img/e_right.png) no-repeat;
+    width: 40px;
+    height: 40px;
+    margin-right: -15px;
+    text-decoration: none;
+    color: #323232;
+}
+.listRotation{
+    border: 1px solid #023246;
+}
+
+/*custom*/
+.top1{
+    position: absolute;
+    top: 9rem;
+    left: 14rem;
+}
+.top2{
+    position: absolute;
+    top: 26.8rem;
+    left: 14rem;
+}