lory-rails 0.2.0 → 0.2.1

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: 03e490ca9f7a3fefaa91d4459eba6791ec9c364a
4
- data.tar.gz: 20ed2657a319b4607ecf6740aa79a34c3163f383
3
+ metadata.gz: 5327acfeb94c62b926ec12ece57ec3cf14a6bb0e
4
+ data.tar.gz: 28c23f3f8af8df43d8b2df3288b08270aeda0ddb
5
5
  SHA512:
6
- metadata.gz: 24408fa4543dd7538f72405c0138868079d6ea5d9b2eacac5320b51bfd97532dc0db49cd561dd7350d12d57684ce6b7fe50e48b20d9448863f623128f9da73d0
7
- data.tar.gz: 6cdb6880244b613ae122eafd9c1fcea80a80af48963d085034fa2b1c2a4bdc3134d01e1865f1adc6d88c36b05cefd6ed2da85e587bf028833b5e4cc51c4311f2
6
+ metadata.gz: 307d53c648d4d56ffcf797b79686bbc686eada001ddc9d105e3bca10b6d3c8b1256ff9b68ddeae8c8b9332e1eacd94b302848e127eebd7dedd427643cc7c331e
7
+ data.tar.gz: f262abf10f99b9e82e075175706d73d7aae76ff00738aad8bb228ce46c7d8851a9cd3e8d0c57d6d3ae7978b0b462d779c05e5eb8c751b891ac47218887faec23
@@ -8,3 +8,4 @@
8
8
  | 0.1.3 | 2.4.3
9
9
  | 0.1.4 | 2.4.4
10
10
  | 0.2.0 | 2.5.0
11
+ | 0.2.1 | 2.5.1
@@ -1,5 +1,5 @@
1
1
  module Lory
2
2
  module Rails
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -242,6 +242,13 @@ function lory(slider, opts) {
242
242
  }
243
243
  }
244
244
 
245
+ /**
246
+ * returns an element's width
247
+ */
248
+ function elementWidth(element) {
249
+ return element.getBoundingClientRect().width || element.offsetWidth;
250
+ }
251
+
245
252
  /**
246
253
  * slidefunction called by prev, next & touchend
247
254
  *
@@ -448,12 +455,12 @@ function lory(slider, opts) {
448
455
  initialIndex = _options5.initialIndex;
449
456
 
450
457
 
451
- slidesWidth = slideContainer.getBoundingClientRect().width || slideContainer.offsetWidth;
452
- frameWidth = frame.getBoundingClientRect().width || frame.offsetWidth;
458
+ slidesWidth = elementWidth(slideContainer);
459
+ frameWidth = elementWidth(frame);
453
460
 
454
461
  if (frameWidth === slidesWidth) {
455
462
  slidesWidth = slides.reduce(function (previousValue, slide) {
456
- return previousValue + slide.getBoundingClientRect().width || slide.offsetWidth;
463
+ return previousValue + elementWidth(slide);
457
464
  }, 0);
458
465
  }
459
466
 
@@ -687,11 +694,13 @@ function lory(slider, opts) {
687
694
  }
688
695
 
689
696
  function onResize(event) {
690
- reset();
697
+ if (frameWidth !== elementWidth(frame)) {
698
+ reset();
691
699
 
692
- dispatchSliderEvent('on', 'resize', {
693
- event: event
694
- });
700
+ dispatchSliderEvent('on', 'resize', {
701
+ event: event
702
+ });
703
+ }
695
704
  }
696
705
 
697
706
  // trigger initial setup
@@ -242,6 +242,13 @@ function lory(slider, opts) {
242
242
  }
243
243
  }
244
244
 
245
+ /**
246
+ * returns an element's width
247
+ */
248
+ function elementWidth(element) {
249
+ return element.getBoundingClientRect().width || element.offsetWidth;
250
+ }
251
+
245
252
  /**
246
253
  * slidefunction called by prev, next & touchend
247
254
  *
@@ -448,12 +455,12 @@ function lory(slider, opts) {
448
455
  initialIndex = _options5.initialIndex;
449
456
 
450
457
 
451
- slidesWidth = slideContainer.getBoundingClientRect().width || slideContainer.offsetWidth;
452
- frameWidth = frame.getBoundingClientRect().width || frame.offsetWidth;
458
+ slidesWidth = elementWidth(slideContainer);
459
+ frameWidth = elementWidth(frame);
453
460
 
454
461
  if (frameWidth === slidesWidth) {
455
462
  slidesWidth = slides.reduce(function (previousValue, slide) {
456
- return previousValue + slide.getBoundingClientRect().width || slide.offsetWidth;
463
+ return previousValue + elementWidth(slide);
457
464
  }, 0);
458
465
  }
459
466
 
@@ -687,11 +694,13 @@ function lory(slider, opts) {
687
694
  }
688
695
 
689
696
  function onResize(event) {
690
- reset();
697
+ if (frameWidth !== elementWidth(frame)) {
698
+ reset();
691
699
 
692
- dispatchSliderEvent('on', 'resize', {
693
- event: event
694
- });
700
+ dispatchSliderEvent('on', 'resize', {
701
+ event: event
702
+ });
703
+ }
695
704
  }
696
705
 
697
706
  // trigger initial setup
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lory-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tanvir hasan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-04 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler