-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniela Valero
committed
Mar 18, 2023
1 parent
78d1a75
commit 41e82c5
Showing
4 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const sidebar = document.querySelector('.md-sidebar--primary'); | ||
sidebar.classList.add('js-resizable'); | ||
|
||
const resizableElem = document.querySelector('.js-resizable'); | ||
resizableElem.classList.toggle('.resizable') | ||
|
||
|
||
const resizer = document.createElement('div'); | ||
resizer.className = 'resizer-elem'; | ||
resizableElem.appendChild(resizer); | ||
resizer.addEventListener('mousedown', initDrag, false); | ||
|
||
|
||
let startX, startY, startWidth, startHeight; | ||
|
||
function initDrag(e) { | ||
startX = e.clientX; | ||
startY = e.clientY; | ||
startWidth = parseInt(document.defaultView.getComputedStyle(resizableElem).width, 10); | ||
startHeight = parseInt(document.defaultView.getComputedStyle(resizableElem).height, 10); | ||
document.documentElement.addEventListener('mousemove', doDrag, false); | ||
document.documentElement.addEventListener('mouseup', stopDrag, false); | ||
} | ||
|
||
function doDrag(e) { | ||
resizableElem.style.width = (startWidth + e.clientX - startX) + 'px'; | ||
resizableElem.style.height = (startHeight + e.clientY - startY) + 'px'; | ||
console.log(startWidth, e, startX, resizableElem.style.width); | ||
} | ||
|
||
function stopDrag(e) { | ||
document.documentElement.removeEventListener('mousemove', doDrag, false); | ||
document.documentElement.removeEventListener('mouseup', stopDrag, false); | ||
} |
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