Home Web Front-end JS Tutorial jQuery realizes blinds focus chart animation effect code sharing (with source code download)_jquery

jQuery realizes blinds focus chart animation effect code sharing (with source code download)_jquery

May 16, 2016 pm 03:10 PM

This is a shutter focus image animation based on jQuery. Different from the CSS3 shutter focus image animation introduced before, it is more compatible and more practical because it is based on pure jQuery. Basically All browsers are supported. The image switching animation of the focus image is the animation method of the blinds, but there are also several different blind animations, so it will not feel monotonous.


Online Demonstration Source code download

HTML code

1

2

3

4

5

<div id="slider">

<img src="/static/imghw/default1.png"  data-src="images/1.jpg"  class="lazy" alt="jQuery realizes blinds focus chart animation effect code sharing (with source code download)_jquery" title="脚本之家大全" />

<img src="/static/imghw/default1.png"  data-src="images/2.jpg"  class="lazy" alt="脚本之家2" title="脚本之家大全" />

<img src="/static/imghw/default1.png"  data-src="images/3.jpg"  class="lazy" alt="脚本之家3" title="脚本之家大全" />

</div>

Copy after login

CSS code

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

#slider {

position: relative;

width: 600px;

overflow: hidden;

margin: 10px auto 30px auto;

}

#slider li {

position: absolute;

top: 0;

left: 0;

}

.caption {

opacity: 0.8;

background: #000;

height: 33px;

padding: 5px 0 0 0;

color: #fff;

text-align: center;

font: 25px/1 '微软雅黑';

z-index: 200;

}

.prev-link, .next-link {

display: block;

width: 24px;

height: 24px;

background-repeat: no-repeat;

background-position: left top;

position: absolute;

bottom: 10px;

z-index: 300;

}

.prev-link {

left: 10px;

background-image: url(prev.png );

}

.next-link {

left: 40px;

background-image: url(next.png );

}

.circle {

display: block;

width: 16px;

height: 16px;

background: url(circle-empty.png ) no-repeat left top;

position: absolute;

bottom: 10px;

z-index: 300;

}

.circle-current {

background-image: url(circle-full.png );

}

Copy after login

JavaScript code

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

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

(function(a) { (function() {

var b = false;

var c = (/xyz/.test(function() {

xyz

})) &#63; (/\b_super\b/) : (/.*/);

this.Class = function() {};

Class.extend = function(h) {

var g = this.prototype;

b = true;

var f = new this();

b = false;

for (var e in h) {

if (typeof h[e] == "function" && typeof g[e] == "function" && c.test(h[e])) {

f[e] = (function(i, j) {

return function() {

var l = this._super;

this._super = g[i];

var k = j.apply(this, arguments);

this._super = l;

return k

}

})(e, h[e])

} else {

f[e] = h[e]

}

}

function d() {

if (!b && this.init) {

this.init.apply(this, arguments)

}

}

d.prototype = f;

d.constructor = d;

d.extend = arguments.callee;

return d

}

})();

a.fn.lateralSlider = function(b) {

var d = {

displayDuration: 2000,

animateDuration: 1500,

numColumns: 10,

transitions: "fade,slideUp,slideDown,slideLeft,slideRight,slideUpAndDown,slideLeftAndRight,fadeAndSlideUp,fadeAndSlideDown,fadeAndSlideLeft,fadeAndSlideRight,fadeSlideUpAndRight,fadeSlideDownAndLeft",

random: false,

hidePrevAndNextArrows: false,

hideSlideChooser: false,

captionOpacity: 0.8

};

var c = a.extend({},

d, b);

this.each(function() {

var j = a(this);

var t = Class.extend({

$imgs: null,

size: null,

displayImg: null,

nextImg: null,

numDivs: null,

divWidth: null,

baseCSS: null,

$divs: null,

transitions: [],

transition: null,

transitionCount: null,

interval: null,

width: null,

init: function() {

this.$imgs = a("img", j);

this.size = this.$imgs.size();

this.$imgs.hide();

this.nextImg = 0;

this.width = j.width();

this.numDivs = c.numColumns;

this.divWidth = this.width / this.numDivs;

this.baseCSS = {

width: this.divWidth,

position: "absolute",

top: 0,

backgroundRepeat: "no-repeat"

};

this.createDivs();

this.$divs = a("div", j);

this.transitionCount = -1

},

createDivs: function() {

for (var A = 0; A < this.numDivs; A++) {

var B = a("<div></div>");

B.css(this.baseCSS);

B.css("left", this.divWidth * A);

B.appendTo(j)

}

}

});

var y = new t();

var g = Class.extend({

baseDuration: null,

originalOffset: null,

offset: null,

init: function() {

this.baseDuration = c.animateDuration / 8;

this.originalOffset = 7 * c.animateDuration / (8 * y.numDivs);

this.offset = 7 * c.animateDuration / (8 * y.numDivs)

},

duration: function() {

return this.baseDuration + this.offset

},

increment: function() {

this.offset += this.originalOffset

},

reset: function() {

this.offset = this.originalOffset

},

getCSS: function(A) {

return {}

},

eachDiv: function() {

return {}

},

applyTransition: function() {

y.$divs.each(this.eachDiv);

this.reset()

}

});

var v = g.extend({

applyTransition: function() {

var A = this;

y.$divs.each(function() {

var B = A.eachDiv;

if (typeof(A.eachDiv) == "function") {

B = B()

}

a(this).animate(B, A.duration());

A.increment()

});

this.reset()

}

});

var m = v.extend({

getCSSIndex: null,

eachDivIndex: null,

getCSSGroup: null,

eachDivGroup: null,

init: function() {

this._super();

this.getCSSGroup = new Array();

this.eachDivGroup = new Array();

this.getCSSIndex = 0;

this.eachDivIndex = 0

},

getCSS: function(B) {

var A = this.getCSSGroup[this.getCSSIndex];

this.getCSSIndex = (this.getCSSIndex + 1) % this.getCSSGroup.length;

return A(B)

},

addTransition: function(A) {

this.getCSSGroup.push(A.getCSS);

this.eachDivGroup.push(A.eachDiv)

},

applyTransition: function() {

var A = this;

y.$divs.each(function() {

var B = A.eachDivGroup[A.eachDivIndex];

if (typeof(B) == "function") {

B = B()

}

a(this).animate(B, A.duration());

A.eachDivIndex = (A.eachDivIndex + 1) % A.eachDivGroup.length;

A.increment()

});

this.reset()

}

});

var u = v.extend({

getCSS: function(A) {

return {

opacity: 0

}

},

eachDiv: {

opacity: 1

}

});

var f = v.extend({

getCSS: function(A) {

return {

top: y.$imgs.eq(y.nextImg).height()

}

},

eachDiv: {

top: 0

}

});

var h = v.extend({

getCSS: function(A) {

return {

height: 0

}

},

eachDiv: function() {

return {

height: y.$imgs.eq(y.nextImg).height()

}

}

});

var r = v.extend({

getCSS: function(B) {

var A = B.css("left");

A = parseInt(A.substring(0, A.length - 2), 10);

return {

left: A + y.divWidth,

width: 0

}

},

eachDiv: {

left: "-=" + y.divWidth,

width: y.divWidth

}

});

var q = v.extend({

getCSS: function(A) {

return {

width: 0

}

},

eachDiv: {

width: y.divWidth

}

});

var o = m.extend({

addTransitions: function(A, B) {

this.addTransition(A);

this.addTransition(B)

}

});

var w = m.extend({

addTransitions: function(B, A) {

this.addTransition(B);

this.addTransition(A)

}

});

var k = m.extend({

addTransitions: function(A, B) {

this.addTransition(A);

this.addTransition(B)

}

});

var n = m.extend({

addTransitions: function(A, B) {

this.addTransition(A);

this.addTransition(B)

}

});

var p = m.extend({

addTransitions: function(A, B) {

this.addTransition(A);

this.addTransition(B)

}

});

var e = m.extend({

addTransitions: function(A, B) {

this.addTransition(A);

this.addTransition(B)

}

});

var x = m.extend({

addTransitions: function(A, C, B) {

this.addTransition(A);

this.addTransition(C);

this.addTransition(B)

}

});

var s = m.extend({

addTransitions: function(C, A, B) {

this.addTransition(C);

this.addTransition(A);

this.addTransition(B)

}

});

var z = {

fade: new u(),

slideUp: new f(),

slideDown: new h(),

slideLeft: new r(),

slideRight: new q(),

slideUpAndDown: new o(),

slideLeftAndRight: new w(),

fadeAndSlideUp: new k(),

fadeAndSlideDown: new n(),

fadeAndSlideLeft: new p(),

fadeAndSlideRight: new e(),

fadeSlideUpAndRight: new x(),

fadeSlideDownAndLeft: new s()

};

z.slideUpAndDown.addTransitions(z.slideUp, z.slideDown);

z.slideLeftAndRight.addTransitions(z.slideLeft, z.slideRight);

z.fadeAndSlideUp.addTransitions(z.slideUp, z.fade);

z.fadeAndSlideDown.addTransitions(z.fade, z.slideDown);

z.fadeAndSlideLeft.addTransitions(z.fade, z.slideLeft);

z.fadeAndSlideRight.addTransitions(z.slideRight, z.fade);

z.fadeSlideUpAndRight.addTransitions(z.slideUp, z.fade, z.slideRight);

z.fadeSlideDownAndLeft.addTransitions(z.slideDown, z.fade, z.slideLeft);

t.prototype.populateTransitions = function() {

var B = c.transitions.split(/,\s*/g);

for (var A in B) {

this.transitions.push(z[B[A]])

}

};

t.prototype.getTransition = function() {

if (c.random) {

var A = Math.floor(Math.random() * this.transitions.length);

return this.transitions[A]

} else {

this.transitionCount = (this.transitionCount + 1) % this.transitions.length;

return this.transitions[this.transitionCount]

}

};

t.prototype.addDivCSS = function() {

var B = this;

var C = B.$imgs.eq(B.nextImg);

var D = "url(" + C.attr("src") + ")";

var A = C.height();

this.$divs.each(function() {

var E = a(this);

E.css({

backgroundImage: D,

backgroundPosition: "-" + E.css("left") + " 0px",

height: A

});

E.css(B.transition.getCSS(E))

})

};

t.prototype.process = function() {

j.css({

backgroundImage: "url(" + this.$imgs.eq(this.displayImg).attr("src") + ")",

backgroundRepeat: "no-repeat"

});

this.transition = this.getTransition();

this.addDivCSS();

this.transition.applyTransition();

j.animate({

height: this.$imgs.eq(this.nextImg).height()

},

c.animateDuration);

this.advanceShow()

};

t.prototype.updateCurrent = function() {

a('.circle[rel="' + this.displayImg + '"]').removeClass("circle-current");

a('.circle[rel="' + this.nextImg + '"]').addClass("circle-current")

};

t.prototype.advanceShow = function() {

this.updateCurrent();

this.displayImg = this.nextImg;

if (this.nextImg == this.size - 1) {

this.nextImg = 0

} else {

this.nextImg++

}

};

t.prototype.startShow = function() {

this.interval = window.setInterval(a.proxy(this.runner, this), c.displayDuration + c.animateDuration)

};

t.prototype.stopShow = function() {

window.clearInterval(this.interval)

};

t.prototype.goToSlide = function(A) {

if (this.$divs.filter(":animated").size() > 0) {

return

}

this.stopShow();

this.nextImg = A;

this.updateCurrent();

this.runner();

if (this.nextImg == 0) {

this.displayImg = this.size - 1

} else {

this.displayImg = this.nextImg - 1

}

this.startShow()

};

t.prototype.applyLink = function() {

var C = this.$imgs.eq(this.displayImg);

var B = C.parent();

if (B.is("a")) {

B.removeAttr("style")

}

var A = this.$imgs.eq(this.nextImg);

var D = A.parent();

if (D.is("a")) {

D.css({

display: "block",

textDecoration: "none",

border: "0",

width: j.width(),

height: A.height(),

position: "absolute",

top: 0,

left: 0,

zIndex: 100

})

}

};

t.prototype.applyCaption = function() {

var A = this.$imgs.eq(this.nextImg);

var C = A.attr("title");

var D = a(".caption", j);

D.slideUp(function() {

a(this).html(C)

});

if (C != "") {

if (D.size() > 0) {

if (!D.is(":visible")) {

D.html(C)

}

D.slideDown()

} else {

var B = a('<div class="caption"><span>' + C + "</span></div>");

B.css({

opacity: c.captionOpacity,

width: j.width(),

position: "absolute",

top: 0,

left: 0,

display: "none"

});

B.appendTo(j);

B.slideDown()

}

}

};

t.prototype.runner = function() {

this.applyLink();

this.applyCaption();

this.process()

};

t.prototype.begin = function() {

var A = this.$imgs.eq(this.nextImg);

j.css({

backgroundImage: "url(" + A.attr("src") + ")",

height: A.height()

});

this.runner();

this.transitionCount--;

this.startShow()

};

var i = Class.extend({

circleCount: null,

init: function() {

this.circleCount = 0

},

addAll: function() {

this.addCircles();

this.addPrevAndNextLinks();

a("a.circle").click(this.circleClickHandler);

a(".prev-link").click(this.prevLinkHandler);

a(".next-link").click(this.nextLinkHandler);

if (c.hideSlideChooser) {

a("a.circle").hide()

}

if (c.hidePrevAndNextArrows) {

a(".prev-link, .next-link").hide()

}

},

addCircles: function() {

var A = this;

y.$imgs.each(function() {

var B = a('<a href="#" rel="' + A.circleCount + '" class="circle"></a>');

B.css({

right: (y.size - A.circleCount - 1) * 20 + 10

});

B.appendTo(j);

A.circleCount++

})

},

addPrevAndNextLinks: function() {

a('<a href="#" class="prev-link"></a>').appendTo(j);

a('<a href="#" class="next-link"></a>').appendTo(j)

},

circleClickHandler: function(B) {

var A = parseInt(a(this).attr("rel"), 10);

y.goToSlide(A);

B.preventDefault()

},

prevLinkHandler: function(B) {

var A = y.displayImg - 1;

if (A < 0) {

A = y.size - 1

}

y.goToSlide(A);

B.preventDefault()

},

nextLinkHandler: function(B) {

var A = y.displayImg + 1;

if (A >= y.size) {

A = 0

}

y.goToSlide(A);

B.preventDefault()

}

});

var l = new i();

l.addAll();

y.populateTransitions();

y.begin()

});

return this

}

})(jQuery);

Copy after login

Of course, don’t forget to reference the jQuery related library files in the web page.

This is where I will introduce you to the jQuery implementation of the shutter focus image animation effect code sharing (with source code download). I hope it will be helpful to you!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1677
14
PHP Tutorial
1280
29
C# Tutorial
1257
24
Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

JavaScript and the Web: Core Functionality and Use Cases JavaScript and the Web: Core Functionality and Use Cases Apr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

JavaScript in Action: Real-World Examples and Projects JavaScript in Action: Real-World Examples and Projects Apr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

Understanding the JavaScript Engine: Implementation Details Understanding the JavaScript Engine: Implementation Details Apr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: Development Environments and Tools Python vs. JavaScript: Development Environments and Tools Apr 26, 2025 am 12:09 AM

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

The Role of C/C   in JavaScript Interpreters and Compilers The Role of C/C in JavaScript Interpreters and Compilers Apr 20, 2025 am 12:01 AM

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

Python vs. JavaScript: Use Cases and Applications Compared Python vs. JavaScript: Use Cases and Applications Compared Apr 21, 2025 am 12:01 AM

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

From Websites to Apps: The Diverse Applications of JavaScript From Websites to Apps: The Diverse Applications of JavaScript Apr 22, 2025 am 12:02 AM

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

See all articles