-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
isOpened added, screen locking fixed
- Loading branch information
Showing
17 changed files
with
234 additions
and
192 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,30 @@ | ||
import {ref} from 'vue' | ||
import {getScrollbarWidth} from '../utils/getScrollbarWidth' | ||
|
||
export function useLock() { | ||
const paddingSize = ref<number | null>(null) | ||
|
||
function getScrollbarWidth(): number { | ||
// Creating invisible container | ||
const outer = document.createElement('div') | ||
outer.style.visibility = 'hidden' | ||
outer.style.overflow = 'scroll' // forcing scrollbar to appear | ||
// outer.style.msOverflowStyle = 'scrollbar' // needed for WinJS apps | ||
document.body.appendChild(outer) | ||
|
||
// Creating inner element and placing it in the container | ||
const inner = document.createElement('div') | ||
outer.appendChild(inner) | ||
|
||
// Calculating difference between container's full width and the child width | ||
const scrollbarWidth = (outer.offsetWidth - inner.offsetWidth) | ||
|
||
// Removing temporary elements from the DOM | ||
outer.parentNode?.removeChild(outer) | ||
|
||
return scrollbarWidth | ||
} | ||
const paddingSize = ref<number | null>(getScrollbarWidth()) | ||
|
||
function lock() { | ||
document.documentElement.style.overflow = 'hidden' | ||
document.body.style.paddingRight = `${paddingSize.value}px` | ||
|
||
if (document.documentElement.scrollHeight > document.documentElement.clientHeight) { | ||
document.body.style.paddingRight = `${paddingSize.value}px` | ||
// document.body.style.width = `calc(100% - ${paddingSize.value}px)` | ||
} | ||
} | ||
|
||
function unlock() { | ||
document.documentElement.style.overflow = 'auto' | ||
document.body.style.paddingRight = '0px' | ||
// document.body.style.width = 'auto' | ||
} | ||
|
||
function toggleLock(value: boolean) { | ||
if (paddingSize.value === null) paddingSize.value = getScrollbarWidth() | ||
value ? lock() : unlock() | ||
} | ||
|
||
return { | ||
paddingSize, | ||
toggleLock | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import ModalTarget from './components/ModalTarget.vue' | ||
|
||
export {useLock} from './composables/useLock' | ||
|
||
export {openModal, confirmModal, closeModal, closeAllModals} from './actions' | ||
|
||
export {isOpened} from './data' | ||
|
||
export {$on, $off} from './event' | ||
|
||
export {createModal} from './plugin' | ||
|
||
export {Events} from './types' | ||
|
||
export { | ||
ModalTarget | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getScrollbarWidth(): number { | ||
// Creating invisible container | ||
const outer = document.createElement('div') | ||
outer.style.visibility = 'hidden' | ||
outer.style.overflow = 'scroll' // forcing scrollbar to appear | ||
// outer.style.msOverflowStyle = 'scrollbar' // needed for WinJS apps | ||
document.body.appendChild(outer) | ||
|
||
// Creating inner element and placing it in the container | ||
const inner = document.createElement('div') | ||
outer.appendChild(inner) | ||
|
||
// Calculating difference between container's full width and the child width | ||
const scrollbarWidth = (outer.offsetWidth - inner.offsetWidth) | ||
|
||
// Removing temporary elements from the DOM | ||
outer.parentNode?.removeChild(outer) | ||
|
||
return scrollbarWidth | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters