photoswipe-rails 4.0.8a → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce0dfc80cced1f6ea74a9b49b6c3c7732e7c6cef
4
- data.tar.gz: 6135e898d3d0771111501eea2ac3a7bbf0085fd4
3
+ metadata.gz: b5e96762270aa9d7ac2d89f20bad5fe689288ec7
4
+ data.tar.gz: b89a3dfd79991ac8d0e9203a17e541afac4bbedc
5
5
  SHA512:
6
- metadata.gz: 65903e19398f4d8b95ffd363d9efd5d25766453b2f4028098090c34106241d3a494b56f1586c2f271781d828e2c7158d138085539069f27c013414d793863f98
7
- data.tar.gz: 3c77da43c04a140ab8940888fee456f85515e82c14254dd03d4c115755098883f6811b950ac2bef33bd30fff277169da6ea274c6dbdea0abad8ce17da07669d7
6
+ metadata.gz: 41faa363a74f39384bfed5d50e02d19f838be81d54a93546772fff8346bc4c21f01dd68fded9bf905536a785c3a9c9a3394fa4a097c1d55bb361b03a96b6664d
7
+ data.tar.gz: 1afd2faec797e4c0b290193f2ac45a77725a0dc29c5cc17ccc29dbbc4716689f4f26e8d2a344aef415a010cdda0c258b2541dfb3689bc5393eee7314b3c66288
@@ -1,4 +1,4 @@
1
- /*! PhotoSwipe Default UI - 4.0.8 - 2015-05-21
1
+ /*! PhotoSwipe Default UI - 4.1.0 - 2015-07-11
2
2
  * http://photoswipe.com
3
3
  * Copyright (c) 2015 Dmitry Semenov; */
4
4
  /**
@@ -1,4 +1,4 @@
1
- /*! PhotoSwipe - v4.0.8 - 2015-05-21
1
+ /*! PhotoSwipe - v4.1.0 - 2015-07-11
2
2
  * http://photoswipe.com
3
3
  * Copyright (c) 2015 Dmitry Semenov; */
4
4
  (function (root, factory) {
@@ -318,7 +318,7 @@ var _options = {
318
318
  pinchToClose: true,
319
319
  closeOnScroll: true,
320
320
  closeOnVerticalDrag: true,
321
- verticalDragRange: 0.6,
321
+ verticalDragRange: 0.75,
322
322
  hideAnimationDuration: 333,
323
323
  showAnimationDuration: 333,
324
324
  showHideOpacity: false,
@@ -334,10 +334,10 @@ var _options = {
334
334
  if(isMouseClick) {
335
335
  return 1;
336
336
  } else {
337
- return item.initialZoomLevel < 0.7 ? 1 : 1.5;
337
+ return item.initialZoomLevel < 0.7 ? 1 : 1.33;
338
338
  }
339
339
  },
340
- maxSpreadZoom: 2,
340
+ maxSpreadZoom: 1.33,
341
341
  modal: true,
342
342
 
343
343
  // not fully implemented yet
@@ -397,6 +397,7 @@ var _isOpen,
397
397
  _currentWindowScrollY,
398
398
  _features,
399
399
  _windowVisibleSize = {},
400
+ _renderMaxResolution = false,
400
401
 
401
402
  // Registers PhotoSWipe module (History, Controller ...)
402
403
  _registerModule = function(name, module) {
@@ -442,21 +443,43 @@ var _isOpen,
442
443
  _bgOpacity = opacity;
443
444
  self.bg.style.opacity = opacity * _options.bgOpacity;
444
445
  },
445
-
446
- _applyZoomTransform = function(styleObj,x,y,zoom) {
446
+
447
+ _applyZoomTransform = function(styleObj,x,y,zoom,item) {
448
+ if(!_renderMaxResolution || (item && item !== self.currItem) ) {
449
+ zoom = zoom / (item ? item.fitRatio : self.currItem.fitRatio);
450
+ }
451
+
447
452
  styleObj[_transformKey] = _translatePrefix + x + 'px, ' + y + 'px' + _translateSufix + ' scale(' + zoom + ')';
448
453
  },
449
- _applyCurrentZoomPan = function() {
454
+ _applyCurrentZoomPan = function( allowRenderResolution ) {
450
455
  if(_currZoomElementStyle) {
456
+
457
+ if(allowRenderResolution) {
458
+ if(_currZoomLevel > self.currItem.fitRatio) {
459
+ if(!_renderMaxResolution) {
460
+ _setImageSize(self.currItem, false, true);
461
+ _renderMaxResolution = true;
462
+ }
463
+ } else {
464
+ if(_renderMaxResolution) {
465
+ _setImageSize(self.currItem);
466
+ _renderMaxResolution = false;
467
+ }
468
+ }
469
+ }
470
+
471
+
451
472
  _applyZoomTransform(_currZoomElementStyle, _panOffset.x, _panOffset.y, _currZoomLevel);
452
473
  }
453
474
  },
454
475
  _applyZoomPanToItem = function(item) {
455
476
  if(item.container) {
477
+
456
478
  _applyZoomTransform(item.container.style,
457
479
  item.initialPosition.x,
458
480
  item.initialPosition.y,
459
- item.initialZoomLevel);
481
+ item.initialZoomLevel,
482
+ item);
460
483
  }
461
484
  },
462
485
  _setTranslateX = function(x, elStyle) {
@@ -772,11 +795,11 @@ var publicMethods = {
772
795
  _currentWindowScrollY = _offset.y = y;
773
796
  _shout('updateScrollOffset', _offset);
774
797
  },
775
- applyZoomPan: function(zoomLevel,panX,panY) {
798
+ applyZoomPan: function(zoomLevel,panX,panY,allowRenderResolution) {
776
799
  _panOffset.x = panX;
777
800
  _panOffset.y = panY;
778
801
  _currZoomLevel = zoomLevel;
779
- _applyCurrentZoomPan();
802
+ _applyCurrentZoomPan( allowRenderResolution );
780
803
  },
781
804
 
782
805
  init: function() {
@@ -1097,6 +1120,7 @@ var publicMethods = {
1097
1120
 
1098
1121
 
1099
1122
  self.currItem = _getItemAt( _currentItemIndex );
1123
+ _renderMaxResolution = false;
1100
1124
 
1101
1125
  _shout('beforeChange', _indexDiff);
1102
1126
 
@@ -1129,7 +1153,8 @@ var publicMethods = {
1129
1153
  var prevItem = _getItemAt(_prevItemIndex);
1130
1154
  if(prevItem.initialZoomLevel !== _currZoomLevel) {
1131
1155
  _calculateItemSize(prevItem , _viewportSize );
1132
- _applyZoomPanToItem( prevItem );
1156
+ _setImageSize(prevItem);
1157
+ _applyZoomPanToItem( prevItem );
1133
1158
  }
1134
1159
 
1135
1160
  }
@@ -1222,6 +1247,7 @@ var publicMethods = {
1222
1247
  }
1223
1248
  if(item && item.container) {
1224
1249
  _calculateItemSize(item, _viewportSize);
1250
+ _setImageSize(item);
1225
1251
  _applyZoomPanToItem( item );
1226
1252
  }
1227
1253
 
@@ -1235,7 +1261,7 @@ var publicMethods = {
1235
1261
  if(_currPanBounds) {
1236
1262
  _panOffset.x = _currPanBounds.center.x;
1237
1263
  _panOffset.y = _currPanBounds.center.y;
1238
- _applyCurrentZoomPan();
1264
+ _applyCurrentZoomPan( true );
1239
1265
  }
1240
1266
 
1241
1267
  _shout('resize');
@@ -1288,7 +1314,7 @@ var publicMethods = {
1288
1314
  updateFn(now);
1289
1315
  }
1290
1316
 
1291
- _applyCurrentZoomPan();
1317
+ _applyCurrentZoomPan( now === 1 );
1292
1318
  };
1293
1319
 
1294
1320
  if(speed) {
@@ -1730,12 +1756,19 @@ var _gestureStartTime,
1730
1756
  if(_isDragging) {
1731
1757
  var touchesList = _getTouchPoints(e);
1732
1758
  if(!_direction && !_moved && !_isZooming) {
1733
- var diff = Math.abs(touchesList[0].x - _currPoint.x) - Math.abs(touchesList[0].y - _currPoint.y);
1734
- // check the direction of movement
1735
- if(Math.abs(diff) >= DIRECTION_CHECK_OFFSET) {
1736
- _direction = diff > 0 ? 'h' : 'v';
1737
- _currentPoints = touchesList;
1759
+
1760
+ if(_mainScrollPos.x !== _slideSize.x * _currPositionIndex) {
1761
+ // if main scroll position is shifted – direction is always horizontal
1762
+ _direction = 'h';
1763
+ } else {
1764
+ var diff = Math.abs(touchesList[0].x - _currPoint.x) - Math.abs(touchesList[0].y - _currPoint.y);
1765
+ // check the direction of movement
1766
+ if(Math.abs(diff) >= DIRECTION_CHECK_OFFSET) {
1767
+ _direction = diff > 0 ? 'h' : 'v';
1768
+ _currentPoints = touchesList;
1769
+ }
1738
1770
  }
1771
+
1739
1772
  } else {
1740
1773
  _currentPoints = touchesList;
1741
1774
  }
@@ -1874,7 +1907,6 @@ var _gestureStartTime,
1874
1907
 
1875
1908
  if(_direction === 'v' && _options.closeOnVerticalDrag) {
1876
1909
  if(!_canPan()) {
1877
-
1878
1910
  _currPanDist.y += delta.y;
1879
1911
  _panOffset.y += delta.y;
1880
1912
 
@@ -2374,13 +2406,11 @@ var _gestureStartTime,
2374
2406
 
2375
2407
  if(_opacityChanged) {
2376
2408
  onUpdate = function(now) {
2377
-
2378
2409
  _applyBgOpacity( (destOpacity - initialOpacity) * now + initialOpacity );
2379
-
2380
2410
  };
2381
2411
  }
2382
2412
 
2383
- self.zoomTo(destZoomLevel, 0, 300, framework.easing.cubic.out, onUpdate);
2413
+ self.zoomTo(destZoomLevel, 0, 200, framework.easing.cubic.out, onUpdate);
2384
2414
  return true;
2385
2415
  };
2386
2416
 
@@ -2773,38 +2803,20 @@ var _getItemAt,
2773
2803
  return;
2774
2804
  }
2775
2805
 
2776
- var animate,
2777
- isSwiping = self.isDragging() && !self.isZooming(),
2778
- slideMightBeVisible = index === _currentItemIndex || self.isMainScrollAnimating() || isSwiping;
2779
-
2780
- // fade in loaded image only when current holder is active, or might be visible
2781
- if(!preventAnimation && (_likelyTouchDevice || _options.alwaysFadeIn) && slideMightBeVisible) {
2782
- animate = true;
2783
- }
2784
-
2785
2806
  if(img) {
2786
- if(animate) {
2787
- img.style.opacity = 0;
2788
- }
2789
2807
 
2790
2808
  item.imageAppended = true;
2791
- _setImageSize(img, item.w, item.h);
2809
+ _setImageSize(item, img);
2792
2810
 
2793
2811
  baseDiv.appendChild(img);
2794
2812
 
2795
- if(animate) {
2813
+ if(keepPlaceholder) {
2796
2814
  setTimeout(function() {
2797
- img.style.opacity = 1;
2798
- if(keepPlaceholder) {
2799
- setTimeout(function() {
2800
- // hide image placeholder "behind"
2801
- if(item && item.loaded && item.placeholder) {
2802
- item.placeholder.style.display = 'none';
2803
- item.placeholder = null;
2804
- }
2805
- }, 500);
2815
+ if(item && item.loaded && item.placeholder) {
2816
+ item.placeholder.style.display = 'none';
2817
+ item.placeholder = null;
2806
2818
  }
2807
- }, 50);
2819
+ }, 500);
2808
2820
  }
2809
2821
  }
2810
2822
  },
@@ -2849,7 +2861,23 @@ var _getItemAt,
2849
2861
 
2850
2862
  }
2851
2863
  },
2852
- _setImageSize = function(img, w, h) {
2864
+ _setImageSize = function(item, img, maxRes) {
2865
+ if(!item.src) {
2866
+ return;
2867
+ }
2868
+
2869
+ if(!img) {
2870
+ img = item.container.lastChild;
2871
+ }
2872
+
2873
+ var w = maxRes ? item.w : Math.round(item.w * item.fitRatio),
2874
+ h = maxRes ? item.h : Math.round(item.h * item.fitRatio);
2875
+
2876
+ if(item.placeholder && !item.loaded) {
2877
+ item.placeholder.style.width = w + 'px';
2878
+ item.placeholder.style.height = h + 'px';
2879
+ }
2880
+
2853
2881
  img.style.width = w + 'px';
2854
2882
  img.style.height = h + 'px';
2855
2883
  },
@@ -2861,7 +2889,7 @@ var _getItemAt,
2861
2889
  for(var i = 0; i < _imagesToAppendPool.length; i++) {
2862
2890
  poolItem = _imagesToAppendPool[i];
2863
2891
  if( poolItem.holder.index === poolItem.index ) {
2864
- _appendImage(poolItem.index, poolItem.item, poolItem.baseDiv, poolItem.img);
2892
+ _appendImage(poolItem.index, poolItem.item, poolItem.baseDiv, poolItem.img, false, poolItem.clearPlaceholder);
2865
2893
  }
2866
2894
  }
2867
2895
  _imagesToAppendPool = [];
@@ -3016,6 +3044,8 @@ _registerModule('Controller', {
3016
3044
  }
3017
3045
 
3018
3046
  _checkForError(item);
3047
+
3048
+ _calculateItemSize(item, _viewportSize);
3019
3049
 
3020
3050
  if(item.src && !item.loadError && !item.loaded) {
3021
3051
 
@@ -3026,14 +3056,6 @@ _registerModule('Controller', {
3026
3056
  return;
3027
3057
  }
3028
3058
 
3029
- // Apply hw-acceleration only after image is loaded.
3030
- // This is webkit progressive image loading bugfix.
3031
- // https://bugs.webkit.org/show_bug.cgi?id=108630
3032
- // https://code.google.com/p/chromium/issues/detail?id=404547
3033
- if(item.img) {
3034
- item.img.style.webkitBackfaceVisibility = 'hidden';
3035
- }
3036
-
3037
3059
  // check if holder hasn't changed while image was loading
3038
3060
  if(holder && holder.index === index ) {
3039
3061
  if( _checkForError(item, true) ) {
@@ -3054,10 +3076,11 @@ _registerModule('Controller', {
3054
3076
  baseDiv:baseDiv,
3055
3077
  img:item.img,
3056
3078
  index:index,
3057
- holder:holder
3079
+ holder:holder,
3080
+ clearPlaceholder:true
3058
3081
  });
3059
3082
  } else {
3060
- _appendImage(index, item, baseDiv, item.img, _mainScrollAnimating || _initialZoomRunning);
3083
+ _appendImage(index, item, baseDiv, item.img, _mainScrollAnimating || _initialZoomRunning, true);
3061
3084
  }
3062
3085
  } else {
3063
3086
  // remove preloader & mini-img
@@ -3084,7 +3107,7 @@ _registerModule('Controller', {
3084
3107
  placeholder.src = item.msrc;
3085
3108
  }
3086
3109
 
3087
- _setImageSize(placeholder, item.w, item.h);
3110
+ _setImageSize(item, placeholder);
3088
3111
 
3089
3112
  baseDiv.appendChild(placeholder);
3090
3113
  item.placeholder = placeholder;
@@ -3117,14 +3140,12 @@ _registerModule('Controller', {
3117
3140
  } else if(item.src && !item.loadError) {
3118
3141
  // image object is created every time, due to bugs of image loading & delay when switching images
3119
3142
  img = framework.createEl('pswp__img', 'img');
3120
- img.style.webkitBackfaceVisibility = 'hidden';
3121
3143
  img.style.opacity = 1;
3122
3144
  img.src = item.src;
3123
- _setImageSize(img, item.w, item.h);
3145
+ _setImageSize(item, img);
3124
3146
  _appendImage(index, item, baseDiv, img, true);
3125
3147
  }
3126
3148
 
3127
- _calculateItemSize(item, _viewportSize);
3128
3149
 
3129
3150
  if(!_initialContentSet && index === _currentItemIndex) {
3130
3151
  _currZoomElementStyle = baseDiv.style;
@@ -3327,9 +3348,9 @@ _registerModule('DesktopZoom', {
3327
3348
  if(_currZoomLevel <= self.currItem.fitRatio) {
3328
3349
  if( _options.modal ) {
3329
3350
 
3330
- if ( !_options.closeOnScroll ) {
3351
+ if (!_options.closeOnScroll || _numAnimations || _isDragging) {
3331
3352
  e.preventDefault();
3332
- } else if( _transformKey && Math.abs(e.deltaY) > 2 ) {
3353
+ } else if(_transformKey && Math.abs(e.deltaY) > 2) {
3333
3354
  // close PhotoSwipe
3334
3355
  // if browser supports transforms & scroll changed enough
3335
3356
  _closedByScroll = true;
@@ -136,9 +136,7 @@
136
136
  width: auto;
137
137
  height: auto;
138
138
  top: 0;
139
- left: 0;
140
- -webkit-transition: opacity 0.15s;
141
- transition: opacity 0.15s; }
139
+ left: 0; }
142
140
 
143
141
  /*
144
142
  stretched thumbnail or div placeholder element (see below)
@@ -1,3 +1,3 @@
1
1
  module PhotoSwipe
2
- VERSION = '4.0.8a'
2
+ VERSION = '4.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photoswipe-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.8a
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristaps Karlsons
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-28 00:00:00.000000000 Z
12
+ date: 2015-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -77,9 +77,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 1.3.1
82
+ version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
85
  rubygems_version: 2.4.6
@@ -87,3 +87,4 @@ signing_key:
87
87
  specification_version: 4
88
88
  summary: Adds PhotoSwipe to your Rails asset pipeline
89
89
  test_files: []
90
+ has_rdoc: