国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服務器之家 - 編程語言 - JavaScript - js教程 - JS相冊圖片抖動放大展示效果的示例代碼

JS相冊圖片抖動放大展示效果的示例代碼

2022-01-12 15:27weixin_33963189 js教程

這篇文章主要介紹了JS相冊圖片抖動放大展示效果的示例代碼,代碼簡單易懂,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

上篇文章給大家介紹了JS實現簡單抖動效果,感興趣的朋友點擊查看。

今天給大家分享JS相冊圖片抖動放大展示效果,效果圖如下所示:

JS相冊圖片抖動放大展示效果的示例代碼

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
var xm;
var ym;
 
/* ==== onmousemove event ==== */
document.onmousemove = function(e){
    if(window.event) e=window.event;
    xm = (e.x || e.clientX);
    ym = (e.y || e.clientY);
}
 
/* ==== window resize ==== */
function resize() {
    if(diapo)diapo.resize();
}
onresize = resize;
 
/* ==== opacity ==== */
setOpacity = function(o, alpha){
    if(o.filters)o.filters.alpha.opacity = alpha * 100; else o.style.opacity = alpha;
}
 
 
 
/* ===== encapsulate script ==== */
diapo = {
    O : [],
    DC : 0,
    img : 0,
    txt : 0,
    N : 0,
    xm : 0,
    ym : 0,
    nx : 0,
    ny : 0,
    nw : 0,
    nh : 0,
    rs : 0,
    rsB : 0,
    zo : 0,
    tx_pos : 0,
    tx_var : 0,
    tx_target : 0,
 
    /// script parameters
    attraction : 2,
    acceleration : .9,
    dampening : .1,
    zoomOver : 2,
    zoomClick : 6,
    transparency : .8,
    font_size: 18,
    //
 
    /* ==== diapo resize ==== */
    resize : function(){
        with(this){
            nx = DC.offsetLeft;
            ny = DC.offsetTop;
            nw = DC.offsetWidth;
            nh = DC.offsetHeight;
            txt.style.fontSize = Math.round(nh / font_size) + "px";
            if(Math.abs(rs-rsB)<100) for(var i=0; i<N; i++) O[i].resize();
            rsB = rs;
        }
    },
 
    /* ==== create diapo ==== */
    CDiapo : function(o){
        /* ==== init variables ==== */
        this.o    = o;
        this.x_pos  = this.y_pos  = 0;
        this.x_origin = this.y_origin = 0;
        this.x_var  = this.y_var  = 0;
        this.x_target = this.y_target = 0;
        this.w_pos  = this.h_pos  = 0;
        this.w_origin = this.h_origin = 0;
        this.w_var  = this.h_var  = 0;
        this.w_target = this.h_target = 0;
        this.over   = false;
        this.click  = false;
 
        /* ==== create shadow ==== */
        this.spa = document.createElement("span");
        this.spa.className = "spaDC";
        diapo.DC.appendChild(this.spa);
 
        /* ==== create thumbnail image ==== */
        this.img = document.createElement("img");
        this.img.className = "imgDC";
        this.img.src = o.src;
        this.img.O = this;
        diapo.DC.appendChild(this.img);
        setOpacity(this.img, diapo.transparency);
 
        /* ==== mouse events ==== */
        this.img.onselectstart = new Function("return false;");
        this.img.ondrag = new Function("return false;");
        this.img.onmouseover = function(){
            diapo.tx_target=0;
            diapo.txt.innerHTML=this.O.o.alt;
            this.O.over=true;
            setOpacity(this,this.O.click?diapo.transparency:1);
        }
        this.img.onmouseout = function(){
            diapo.tx_target=-diapo.nw;
            this.O.over=false;
            setOpacity(this,diapo.transparency);
        }
        this.img.onclick = function() {
            if(!this.O.click){
                if(diapo.zo && diapo.zo != this) diapo.zo.onclick();
                this.O.click = true;
                this.O.x_origin = (diapo.nw - (this.O.w_origin * diapo.zoomClick)) / 2;
                this.O.y_origin = (diapo.nh - (this.O.h_origin * diapo.zoomClick)) / 2;
                diapo.zo = this;
                setOpacity(this,diapo.transparency);
            } else {
                this.O.click = false;
                this.O.over = false;
                this.O.resize();
                diapo.zo = 0;
            }
        }
 
        /* ==== rearrange thumbnails based on "imgsrc" images position ==== */
        this.resize = function (){
            with (this) {
                x_origin = o.offsetLeft;
                y_origin = o.offsetTop;
                w_origin = o.offsetWidth;
                h_origin = o.offsetHeight;
            }
        }
 
        /* ==== animation function ==== */
        this.position = function (){
            with (this) {
                /* ==== set target position ==== */
                w_target = w_origin;
                h_target = h_origin;
                if(over){
                    /* ==== mouse over ==== */
                    w_target = w_origin * diapo.zoomOver;
                    h_target = h_origin * diapo.zoomOver;
                    x_target = diapo.xm - w_pos / 2 - (diapo.xm - (x_origin + w_pos / 2)) / (diapo.attraction*(click?10:1));
                    y_target = diapo.ym - h_pos / 2 - (diapo.ym - (y_origin + h_pos / 2)) / (diapo.attraction*(click?10:1));
                } else {
                    /* ==== mouse out ==== */
                    x_target = x_origin;
                    y_target = y_origin;
                }
                if(click){
                    /* ==== clicked ==== */
                    w_target = w_origin * diapo.zoomClick;
                    h_target = h_origin * diapo.zoomClick;
                }
 
                /* ==== magic spring equations ==== */
                x_pos += x_var = x_var * diapo.acceleration + (x_target - x_pos) * diapo.dampening;
                y_pos += y_var = y_var * diapo.acceleration + (y_target - y_pos) * diapo.dampening;
                w_pos += w_var = w_var * (diapo.acceleration * .5) + (w_target - w_pos) * (diapo.dampening * .5);
                h_pos += h_var = h_var * (diapo.acceleration * .5) + (h_target - h_pos) * (diapo.dampening * .5);
                diapo.rs += (Math.abs(x_var) + Math.abs(y_var));
 
                /* ==== html animation ==== */
                with(img.style){
                    left  = Math.round(x_pos) + "px";
                    top  = Math.round(y_pos) + "px";
                    width = Math.round(Math.max(0, w_pos)) + "px";
                    height = Math.round(Math.max(0, h_pos)) + "px";
                    zIndex = Math.round(w_pos);
                }
                with(spa.style){
                    left  = Math.round(x_pos + w_pos * .1) + "px";
                    top  = Math.round(y_pos + h_pos * .1) + "px";
                    width = Math.round(Math.max(0, w_pos * 1.1)) + "px";
                    height = Math.round(Math.max(0, h_pos * 1.1)) + "px";
                    zIndex = Math.round(w_pos);
                }
            }
        }
    },
 
    /* ==== main loop ==== */
    run : function(){
        diapo.xm = xm - diapo.nx;
        diapo.ym = ym - diapo.ny;
        /* ==== caption anim ==== */
        diapo.tx_pos += diapo.tx_var = diapo.tx_var * .9 + (diapo.tx_target - diapo.tx_pos) * .02;
        diapo.txt.style.left = Math.round(diapo.tx_pos) + "px";
        /* ==== images anim ==== */
        for(var i in diapo.O) diapo.O[i].position();
        /* ==== loop ==== */
        setTimeout("diapo.run();", 16);
    },
 
    /* ==== load images ==== */
    images_load : function(){
        // ===== loop until all images are loaded =====
        var M = 0;
        for(var i=0; i<diapo.N; i++) {
            if(diapo.img[i].complete) {
                diapo.img[i].style.position = "relative";
                diapo.O[i].img.style.visibility = "visible";
                diapo.O[i].spa.style.visibility = "visible";
                M++;
            }
            resize();
        }
        if(M<diapo.N) setTimeout("diapo.images_load();", 128);
    },
 
    /* ==== init script ==== */
    init : function() {
        diapo.DC = document.getElementById("diapoContainer");
        diapo.img = diapo.DC.getElementsByTagName("img");
        diapo.txt = document.getElementById("caption");
        diapo.N = diapo.img.length;
        for(i=0; i<diapo.N; i++) diapo.O.push(new diapo.CDiapo(diapo.img[i]));
        diapo.resize();
        diapo.tx_pos = -diapo.nw;
        diapo.tx_target = -diapo.nw;
        diapo.images_load();
        diapo.run();
    }
}
 
/* ==== start script ==== */
function dom_onload() {
    if(document.getElementById("diapoContainer")) diapo.init(); else setTimeout("dom_onload();", 128);
}
dom_onload();

到此這篇關于JS相冊圖片抖動放大展示效果的示例代碼的文章就介紹到這了,更多相關js圖片放大抖動內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://blog.csdn.net/weixin_33963189/article/details/91988807

延伸 · 閱讀

精彩推薦
  • js教程JavaScript如何實現防止重復的網絡請求的示例

    JavaScript如何實現防止重復的網絡請求的示例

    這篇文章主要介紹了JavaScript如何實現防止重復的網絡請求的示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需...

    Daes11002022-01-10
  • js教程利用JS判斷元素是否為數組的方法示例

    利用JS判斷元素是否為數組的方法示例

    這篇文章主要給大家介紹了關于利用JS判斷元素是否為數組的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價...

    Fahrenheitzz10062021-12-29
  • js教程原生JavaScript實現輪播圖

    原生JavaScript實現輪播圖

    這篇文章主要為大家詳細介紹了原生JavaScript實現輪播圖,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下...

    棟棟很優秀啊6962021-12-29
  • js教程JavaScript實現4位隨機驗證碼的生成

    JavaScript實現4位隨機驗證碼的生成

    這篇文章主要為大家詳細介紹了JavaScript實現4位隨機驗證碼的生成,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下...

    weixin_4202683110402022-01-10
  • js教程使用AutoJs實現微信搶紅包的代碼

    使用AutoJs實現微信搶紅包的代碼

    這篇文章主要介紹了使用AutoJs實現微信搶紅包的代碼,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下...

    王略6032021-12-23
  • js教程確保JavaScript 安全的五大做法

    確保JavaScript 安全的五大做法

    如果你運行交互式網站或應用程序,JavaScript 安全性是重中之重。 從程序錯誤和不安全的用戶輸入到惡意攻擊,有很多事情可能會出錯。...

    粵嵌教育8562022-01-11
  • js教程js閉包的9個使用場景

    js閉包的9個使用場景

    這篇文章主要介紹了js 閉包的9個使用場景,幫助大家更好的理解和學習JavaScript 閉包的使用,感興趣的朋友可以了解下...

    林恒10092021-12-22
  • js教程前端經常會用到的JavaScript方法封裝

    前端經常會用到的JavaScript方法封裝

    前端經常會用到的JavaScript方法封裝都有哪些呢?我們一起來看一下吧!...

    Find一只程序猿11372021-12-30
主站蜘蛛池模板: 激情网站免费观看 | 欧美日本免费一区二区三区 | 国产精品福利视频 | 中文字幕在线观看日韩 | 国产青青草 | 黄色av电影 | 狼人综合av| 91夜夜操 | 国产精品久久国产精品 | 国产精品区二区三区日本 | 久久人 | 一区二区三区 在线 | 日产精品一区二区三区在线观看 | 五月婷婷视频 | 精品粉嫩超白一线天av | 成人免费视频网站在线观看 | 1区2区在线观看 | 成人av免费| 中文在线观看www | 黄色在线 | 免费日韩一级片 | 一级片视频在线观看 | 午夜视频在线观看免费视频 | 亚洲不卡视频 | 国产欧美精品一区二区色综合 | 夜夜福利 | 欧美日韩一区二区在线播放 | 亚洲视频中文字幕 | 亚洲人成在线播放 | 日韩在线一区二区三区 | 国产精品网站在线观看 | 亚洲一区国产视频 | 欧美一区二区三区婷婷月色 | 国产精品福利一区二区三区 | 国产午夜精品久久久久久久 | youjizz国产| 黄色电影免费在线观看 | 欧美日韩视频在线 | 精品国产精品三级精品av网址 | 久久久亚洲国产美女国产盗摄 | 欧美成人一区二免费视频软件 |