mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(ssr): fix global window and document references (#17590)
This commit is contained in:
@ -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)) ||
|
||||
|
Reference in New Issue
Block a user