fix(ssr): fix global window and document references (#17590)

This commit is contained in:
Adam Bradley
2019-02-22 20:13:09 -06:00
committed by GitHub
parent 6bea9d3248
commit 4646f53ec7
18 changed files with 76 additions and 70 deletions

View File

@ -24,6 +24,8 @@ export class Toggle implements ComponentInterface {
@Prop({ context: 'queue' }) queue!: QueueApi;
@Prop({ context: 'document' }) doc!: Document;
@State() activated = false;
/**
@ -146,7 +148,7 @@ export class Toggle implements ComponentInterface {
}
private onMove(detail: GestureDetail) {
if (shouldToggle(this.checked, detail.deltaX, -10)) {
if (shouldToggle(this.doc, this.checked, detail.deltaX, -10)) {
this.checked = !this.checked;
hapticSelection();
}
@ -222,8 +224,8 @@ export class Toggle implements ComponentInterface {
}
}
function shouldToggle(checked: boolean, deltaX: number, margin: number): boolean {
const isRTL = document.dir === 'rtl';
function shouldToggle(doc: HTMLDocument, checked: boolean, deltaX: number, margin: number): boolean {
const isRTL = doc.dir === 'rtl';
if (checked) {
return (!isRTL && (margin > deltaX)) ||