From fd7cd13ce2aa5857ec9b6eb39b7a20317362354b Mon Sep 17 00:00:00 2001 From: massat Date: Wed, 13 Sep 2017 14:02:45 +0900 Subject: [PATCH 1/6] add args --- jquery.flicksimple.js | 56 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/jquery.flicksimple.js b/jquery.flicksimple.js index e81dddb..8bfa2fa 100755 --- a/jquery.flicksimple.js +++ b/jquery.flicksimple.js @@ -7,7 +7,7 @@ * http://www.gnu.org/licenses/gpl.html * */ -(function($){ +(function($, window, document, undefined){ $.flickSimple = function( obj, param ) { this.setup( $(obj), param ); @@ -81,7 +81,7 @@ o.elm = obj; o.elm.css( { overflow: 'hidden' } ); o.target = param.target || $(o.elm.children().get(0)); - + var ua = navigator.userAgent.toLowerCase(); o.android = param.android === void 0 ? ua.indexOf('android') !== -1 @@ -108,7 +108,7 @@ o.onResize = param.onResize; o.onAnimationEnd = param.onAnimationEnd; o.onClick = param.onClick; - + if ( typeof window.onorientationchange === 'object' && ! o.android ) { $(window).bind( 'orientationchange', function(){ o.updateSize(); } ); } else { @@ -126,7 +126,7 @@ o.target.css(css); } o.updateSize(); - + if ( o.touchable ) { o.elm.bind( 'touchstart', function(e){ o.touchstart(e) } ) .bind( 'touchmove', function(e){ o.touchmove(e) } ) @@ -146,24 +146,24 @@ } return o; }, - + // 次のページへ移動 nextPage: function( num ) { return this.goTo( this.page + (num || 1) ); }, - + // 前のページへ移動 prevPage: function( num ) { return this.goTo( this.page - (num || 1) ); }, - + // 指定されたページへ移動 goTo: function( pagenum ) { if ( pagenum > this.pageLength ) { pagenum = this.pageLength; } pagenum--; - + var pageX, pageY, rownum; if ( this.paginate === 'y' ) { rownum = Math.ceil( this.elmHeight / this.pageHeight ) +1; @@ -178,7 +178,7 @@ var posY = pageY * this.pageHeight; return this.move( -posX, -posY ); }, - + // 指定されたX座標に移動 move: function( posX, posY ) { var o = this; @@ -212,7 +212,7 @@ o.nextY = posY; return o.update( posX, posY ); }, - + // 表示が変更されたら、各エレメントの大きさを計算し直す updateSize: function() { var o = this; @@ -221,12 +221,12 @@ : ( window.innerWidth < window.innerHeight ? 'portrait' : 'landscape' ); // var lis = o.target.find('li'); var lis = o.target.children(); - + o.elm.removeClass('landscape portrait').addClass( ori ); // うまく反映されない場合があるので、エレメント自体にclassを振る o.target.removeClass('landscape portrait').addClass( ori ); lis.removeClass('landscape portrait').addClass( ori ); - + var targw = o.target.width(); var targh = o.target.height(); var elmw = o.elm.width(); @@ -253,7 +253,7 @@ } } ); o.pageWidth = smaller; - + smaller = 0; lis.each( function() { var h = $(this).height(); @@ -262,7 +262,7 @@ } } ); o.pageHeight = smaller; - + } else if ( typeof o.snap === 'object' ) { o.pageWidth = o.snap[0]; o.pageHeight = o.snap[1]; @@ -270,13 +270,13 @@ o.pageWidth = o.snap; o.pageHeight = o.snap; } - + o.pageLength = Math.ceil( targw / o.pageWidth ); if ( targh > o.pageHeight ) { o.pageLength *= Math.ceil( targh / o.pageHeight ); } } - + if ( o.onResize ) { o.onResize(); } @@ -299,7 +299,7 @@ if ( anc.length > 0 ) { o.anc = anc; } - + // 長押し対応 setTimeout( function() { if ( o.anc ) { @@ -313,11 +313,11 @@ anc && anc.attr('href', 'javascript:;'); }, 200 ); } - + } }, 600 ); }, - + touchmove: function(e) { var o = this; if ( o.disabled ) { return; } @@ -351,7 +351,7 @@ o.preX = nowX; o.preY = nowY; }, - + touchend: function(e) { var o = this; if ( o.disabled || o.startX === null || o.startY === null ) { return; } @@ -404,8 +404,8 @@ } else if ( nposY < -o.elmHeight ) { nposY = -o.elmHeight; } - - + + if ( ! o.useCSSAnim ) { o.target.animate( { left: nposX + 'px', top: nposY + 'px' }, o.duration, function (x, t, b, c, d) { @@ -421,11 +421,11 @@ css[o.vender.transform] = o.use3d ? 'translate3d(' + nposX + 'px,' + nposY + 'px,0)' : 'translate(' + nposX + 'px,' + nposY + 'px)'; - o.target.css( css ); + o.target.css( css ); } o.update( nposX, nposY ); }, - + update: function( posX, posY ) { var o = this; if ( o.pageWidth || o.pageHeight ) { @@ -449,11 +449,11 @@ } return o; }, - + no_mousedown: function(e) { e.preventDefault(); }, - + // 初期化(内容に変更があった場合には、呼び出すこと) init: function() { var o = this; @@ -471,7 +471,7 @@ .bind( 'mousedown', o.no_mousedown ); } } ); - + // 画像のドラッグをさせない if ( ! o.touchable ) { o.target.find('img') @@ -516,4 +516,4 @@ return res; }; -})(jQuery); +})(jQuery, window, document); From 41e840ca53d4dbe1dc187a50f10b3c0159d6fac5 Mon Sep 17 00:00:00 2001 From: massat Date: Wed, 13 Sep 2017 14:14:21 +0900 Subject: [PATCH 2/6] http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm --- jquery.flicksimple.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jquery.flicksimple.js b/jquery.flicksimple.js index 8bfa2fa..79bc2cc 100755 --- a/jquery.flicksimple.js +++ b/jquery.flicksimple.js @@ -1,5 +1,5 @@ /** - * jQuery.flickSimple v1.2.2 + * jQuery.flickSimple v1.3.0 * * Copyright (c) 2011 Makog. http://d.hatena.ne.jp/makog/ * Dual licensed under the MIT and GPL licenses: @@ -7,7 +7,13 @@ * http://www.gnu.org/licenses/gpl.html * */ -(function($, window, document, undefined){ +(function( factory ) { + if ( typeof module === "object" && typeof module.exports === "object" ) { + module.exports = factory( require( "jquery" ), window, document ); + } else { + factory( jQuery, window, document ); + } +} (function( $, window, document, undefined ) { $.flickSimple = function( obj, param ) { this.setup( $(obj), param ); @@ -515,5 +521,4 @@ } return res; }; - -})(jQuery, window, document); +})); From 153c40a72a5a7740967bffea57b2076317051880 Mon Sep 17 00:00:00 2001 From: massat Date: Wed, 13 Sep 2017 14:24:52 +0900 Subject: [PATCH 3/6] add package.json --- package.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..abaa1f3 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "jQuery.flickSimple.js", + "version": "1.3.0", + "description": "PCのブラウザ、Androidにも対応したフリック動作", + "dependencies": {"jquery": ""}, + "main": "jquery.flicksimple.js", + "repository": "https://github.com/makog/jQuery.flickSimple.js", + "author": "makog (http://d.hatena.ne.jp/makog/)", + "license": "(MIT OR GPL)", + "keywords": "jquery-plugin", + "private": false +} From af710cf040c422bc32a26d91a0dcfe23f5563a94 Mon Sep 17 00:00:00 2001 From: massat Date: Wed, 13 Sep 2017 14:27:07 +0900 Subject: [PATCH 4/6] update --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index d2d61a7..f0bb29e 100755 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.2 \ No newline at end of file +1.3.0 From 8a50891bedf391b0550a305a79720b80276e9672 Mon Sep 17 00:00:00 2001 From: massat Date: Wed, 13 Sep 2017 14:33:44 +0900 Subject: [PATCH 5/6] Fix package name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index abaa1f3..dc2941c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "jQuery.flickSimple.js", + "name": "jquery-flickSimple", "version": "1.3.0", "description": "PCのブラウザ、Androidにも対応したフリック動作", "dependencies": {"jquery": ""}, From 0c63c39a8f71ee696c8237adb2bc82dbfb83ccf5 Mon Sep 17 00:00:00 2001 From: massat Date: Wed, 13 Sep 2017 19:47:44 +0900 Subject: [PATCH 6/6] typo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc2941c..af178a5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "jquery-flickSimple", + "name": "jquery-flicksimple", "version": "1.3.0", "description": "PCのブラウザ、Androidにも対応したフリック動作", "dependencies": {"jquery": ""},