Skip to content

Commit

Permalink
Moved is-web-kit to vi-scroller
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleeckx committed Jul 22, 2016
1 parent 12aaa44 commit 09e1813
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
15 changes: 0 additions & 15 deletions src/WebComponents/App/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ namespace Vidyano.WebComponents {
type: String,
reflectToAttribute: true,
observer: "_cookiePrefixChanged"
},
isWebKit: {
type: Boolean,
reflectToAttribute: true,
computed: "_computeIsWebKit(isAttached)"
}
},
observers: [
Expand Down Expand Up @@ -256,7 +251,6 @@ namespace Vidyano.WebComponents {
label: string;
keys: string;
isTracking: boolean;
isWebKit: boolean;

private _setConfiguration: (config: AppConfig) => void;
private _setInitializing: (init: boolean) => void;
Expand All @@ -270,11 +264,6 @@ namespace Vidyano.WebComponents {
attached() {
super.attached();

if (!this.isWebKit) {
this.customStyle["--theme-scrollbar-width"] = `${scrollbarWidth()}px`;
this.updateStyles();
}

if (!this.label)
this.label = this.title;

Expand Down Expand Up @@ -722,10 +711,6 @@ namespace Vidyano.WebComponents {
});
}

private _computeIsWebKit(): boolean {
return "WebkitAppearance" in document.documentElement.style;
}

private _resolveDependencies(hasManagement: boolean) {
this.importComponent("PopupMenu");
}
Expand Down
30 changes: 15 additions & 15 deletions src/WebComponents/Scroller/scroller.scss
Original file line number Diff line number Diff line change
Expand Up @@ -233,24 +233,24 @@
&[scroll-bottom-shadow] > .scroll-shadow.bottom {
transform: translateY(var(--theme-h2));
}
}

:host-context(vi-app[is-web-kit]) {
> #wrapper::-webkit-scrollbar {
display: none;
}
&[is-web-kit] {
> #wrapper::-webkit-scrollbar {
display: none;
}

// Edge also reports being webkit
> #wrapper {
-ms-overflow-style: none;
// Edge also reports being webkit
> #wrapper {
-ms-overflow-style: none;
}
}
}

:host-context(vi-app:not([is-web-kit])) {
> #wrapper {
margin-right: calc(var(--theme-scrollbar-width) * -1);
margin-bottom: calc(var(--theme-scrollbar-width) * -1);
padding-right: var(--theme-scrollbar-width);
padding-bottom: var(--theme-scrollbar-width);
&not([is-web-kit]) {
> #wrapper {
margin-right: calc(var(--theme-scrollbar-width) * -1);
margin-bottom: calc(var(--theme-scrollbar-width) * -1);
padding-right: var(--theme-scrollbar-width);
padding-bottom: var(--theme-scrollbar-width);
}
}
}
21 changes: 20 additions & 1 deletion src/WebComponents/Scroller/scroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
type: Boolean,
readOnly: true,
reflectToAttribute: true
},
isWebKit: {
type: Boolean,
reflectToAttribute: true,
computed: "_computeIsWebKit(isAttached)"
}
},
forwardObservers: [
Expand Down Expand Up @@ -146,6 +151,7 @@
verticalScrollOffset: number;
forceScrollbars: boolean;
noScrollShadow: boolean;
isWebKit: boolean;

private _setAtTop: (atTop: boolean) => void;
private _setOuterWidth: (width: number) => void;
Expand All @@ -158,6 +164,15 @@
private _setScrollBottomShadow: (val: boolean) => void;
private _setHiddenScrollbars: (val: boolean) => void;

attached() {
super.attached();

if (!this.isWebKit) {
this.customStyle["--theme-scrollbar-width"] = `${scrollbarWidth()}px`;
this.updateStyles();
}
}

get scroller(): HTMLElement {
// NOTE: This property is used by other components to determine the scrolling parent.
return this.$["wrapper"];
Expand Down Expand Up @@ -195,7 +210,7 @@
}

private _outerSizeChanged(e: Event, detail: { width: number; height: number }) {
this._setHiddenScrollbars(!this.app.isWebKit && !parseInt(this.getComputedStyleValue("--theme-scrollbar-width")));
this._setHiddenScrollbars(!this.isWebKit && !parseInt(this.getComputedStyleValue("--theme-scrollbar-width")));

this._setOuterWidth(detail.width);
this._setOuterHeight(detail.height);
Expand Down Expand Up @@ -379,5 +394,9 @@
e.stopPropagation();
}
}

private _computeIsWebKit(): boolean {
return "WebkitAppearance" in document.documentElement.style;
}
}
}

0 comments on commit 09e1813

Please sign in to comment.