Skip to content

Commit

Permalink
perf: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
janschoenherr committed Sep 21, 2018
1 parent 894b245 commit b14374d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/js/core/height-viewport.js
Expand Up @@ -27,22 +27,22 @@ export default {

read() {

const viewport = height(window);
let minHeight = '';

if (this.expand) {

minHeight = viewport - (offsetHeight(document.documentElement) - offsetHeight(this.$el)) || '';
minHeight = height(window) - (offsetHeight(document.documentElement) - offsetHeight(this.$el)) || '';

} else {

const {top} = offset(this.$el);

// on mobile devices (iOS and Android) window.innerHeight !== 100vh
minHeight = 'calc(100vh';

if (top < viewport / 2 && this.offsetTop) {
minHeight += ` - ${top}px`;
if (this.offsetTop) {

const {top} = offset(this.$el);
minHeight += top < height(window) / 2 ? ` - ${top}px` : '';

}

if (this.offsetBottom === true) {
Expand All @@ -67,7 +67,7 @@ export default {

}

return {minHeight, viewport};
return {minHeight};
},

write({minHeight}) {
Expand Down
12 changes: 5 additions & 7 deletions src/js/core/sticky.js
Expand Up @@ -135,19 +135,17 @@ export default {

read() {
return {
height: this.$el.offsetHeight,
top: offset(this.isActive ? this.placeholder : this.$el).top
top: offset(this.isActive ? this.placeholder : this.$el).top,
height: css(this.$el, 'position') !== 'absolute' ? this.$el.offsetHeight : '',
margins: css(this.$el, ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'])
};
},

write({height, top}) {
write({height, top, margins}) {

const {placeholder} = this;

css(placeholder, assign(
{height: css(this.$el, 'position') !== 'absolute' ? height : ''},
css(this.$el, ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'])
));
css(placeholder, assign({height}, margins));

if (!within(placeholder, document)) {
after(this.$el, placeholder);
Expand Down

0 comments on commit b14374d

Please sign in to comment.