Skip to content

Commit cbb740a

Browse files
committed
Change version number to 1.1.2. Fix: issue calculating element's size for SVG on Firefox.
1 parent b015f3c commit cbb740a

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ This will install all the necessary tools for compiling minified files.
103103
__1.1.2__
104104

105105
- Improvement: Extend public method `getScrollPercent` to return scroll percentage for elements.
106-
- Fix position calculation to 2 decimals precision.
107-
- Fix scroll percent calculation based on containerSize.
106+
- Fix: issue calculating element's size for SVG on Firefox
107+
- Fix: position calculation to 2 decimals precision for better performance.
108+
- Fix: scroll percent calculation based on `containerSize`.
108109

109110
__1.1.1__
110111

dist/smooth-parallax.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,15 @@
244244
baseHeight,
245245
transformValue;
246246

247+
// Try get element's size with `scrollWidth` and `scrollHeight`
248+
// otherwise use `getComputedStyle` which is more expensive
247249
if ( p.baseSizeOn == 'elementSize' ) {
248-
baseWidth = _movingElements[i].scrollWidth;
249-
baseHeight = _movingElements[i].scrollHeight;
250+
baseWidth = _movingElements[i].scrollWidth || parseFloat( window.getComputedStyle( _movingElements[i] ).width );
251+
baseHeight = _movingElements[i].scrollHeight || parseFloat( window.getComputedStyle( _movingElements[i] ).height );
250252
}
251253
else if ( p.baseSizeOn == 'containerSize' ) {
252-
baseWidth = p.container.scrollWidth - _movingElements[i].scrollWidth;
253-
baseHeight = p.container.scrollHeight - _movingElements[i].scrollHeight;
254+
baseWidth = p.container.scrollWidth - (_movingElements[i].scrollWidth || parseFloat( window.getComputedStyle( _movingElements[i] ).width ) );
255+
baseHeight = p.container.scrollHeight - (_movingElements[i].scrollHeight || parseFloat( window.getComputedStyle( _movingElements[i] ).height ) );
254256
}
255257

256258
// Need to calculate percentage for each element

dist/smooth-parallax.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/smooth-parallax-src.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,15 @@
244244
baseHeight,
245245
transformValue;
246246

247+
// Try get element's size with `scrollWidth` and `scrollHeight`
248+
// otherwise use `getComputedStyle` which is more expensive
247249
if ( p.baseSizeOn == 'elementSize' ) {
248-
baseWidth = _movingElements[i].scrollWidth;
249-
baseHeight = _movingElements[i].scrollHeight;
250+
baseWidth = _movingElements[i].scrollWidth || parseFloat( window.getComputedStyle( _movingElements[i] ).width );
251+
baseHeight = _movingElements[i].scrollHeight || parseFloat( window.getComputedStyle( _movingElements[i] ).height );
250252
}
251253
else if ( p.baseSizeOn == 'containerSize' ) {
252-
baseWidth = p.container.scrollWidth - _movingElements[i].scrollWidth;
253-
baseHeight = p.container.scrollHeight - _movingElements[i].scrollHeight;
254+
baseWidth = p.container.scrollWidth - (_movingElements[i].scrollWidth || parseFloat( window.getComputedStyle( _movingElements[i] ).width ) );
255+
baseHeight = p.container.scrollHeight - (_movingElements[i].scrollHeight || parseFloat( window.getComputedStyle( _movingElements[i] ).height ) );
254256
}
255257

256258
// Need to calculate percentage for each element

0 commit comments

Comments
 (0)