Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 46a0db2

Browse files
committed
support zepto
1 parent b291c22 commit 46a0db2

File tree

5 files changed

+1660
-6
lines changed

5 files changed

+1660
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#### Playground
66
[http://blackmiaool.com/jquery-image-explode/playground.html](http://blackmiaool.com/jquery-image-explode/playground.html)
77

8+
Compatible with zepto.
9+
810
MIT license
911

1012
[npm-url]: https://www.npmjs.com/package/jquery-image-explode

dist/jquery.imgexplode.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
<img id="target" src="./demo.jpg" />
3737
<button style="position:fixed;right:0;top:0;width:100px;height:50px;" onclick="explode()">Explode</button>
3838
<script src="lib/jquery-3.1.0.js"></script>
39-
<!-- <script src="jquery.imgexplode.js"></script>-->
39+
<!--<script src="lib/zepto1.2.0.js"></script>-->
40+
<!--<script src="jquery.imgexplode.js"></script>-->
4041
<script src="dist/jquery.imgexplode.min.js"></script>
4142
<script>
4243
var $target = $("#target");

jquery.imgexplode.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"use strict";
33
const wrapperName = "explode-wrapper";
44
if(!$){
5-
console.error("jQuery is needed.");
5+
console.error("jQuery or Zepto is needed.");
66
return;
77
}
88
$.fn.explodeRestore = function () {
@@ -401,9 +401,10 @@
401401
return parseInt(Math.random() * (max + 1 - min), 10) + min;
402402
}
403403
function shuffle(array) {
404-
var currentIndex = array.length, temporaryValue, randomIndex;
404+
let currentIndex = array.length, temporaryValue, randomIndex;
405405
while (currentIndex) {
406406
randomIndex = Math.floor(Math.random() * currentIndex);
407+
currentIndex -= 1;
407408
temporaryValue = array[currentIndex];
408409
array[currentIndex] = array[randomIndex];
409410
array[randomIndex] = temporaryValue;
@@ -573,4 +574,4 @@
573574
return ret;
574575
}
575576
};
576-
})(window.jQuery);
577+
})(window.jQuery||window.Zepto);

0 commit comments

Comments
 (0)