-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from belsman/feat/add-animation-to-layer
feat: add entry and exit animation on the layer module
- Loading branch information
Showing
6 changed files
with
299 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
@use "../button.scss" as *; | ||
@use "../flex-grid.scss"; | ||
@use "../icogram.scss" as *; | ||
@use "../icon.scss" as *; | ||
@use "../loose-button-group.scss"; | ||
@use "../panel.scss" as *; | ||
@use "../size-modulation.scss"; | ||
@use "../typography.scss" as *; | ||
@use "../utils.scss" as *; | ||
@use "../theme.scss" as *; | ||
@use "./index.scss"; | ||
@use '../button.scss' as *; | ||
@use '../flex-grid.scss'; | ||
@use '../icogram.scss' as *; | ||
@use '../icon.scss' as *; | ||
@use '../loose-button-group.scss'; | ||
@use '../panel.scss' as *; | ||
@use '../size-modulation.scss'; | ||
@use '../typography.scss' as *; | ||
@use '../utils.scss' as *; | ||
@use '../theme.scss' as *; | ||
@use './index.scss'; | ||
|
||
.example-layer-width-animation { | ||
width: 100%; | ||
height: 400px; | ||
background-color: #f9f9ff; | ||
} |
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,103 @@ | ||
<div class="example-layer-width-animation"> | ||
<button id="showDialog" type="button" class="button emphasized"> | ||
<div class="icogram"><span class="text">Show Dialog</span></div> | ||
</button> | ||
</div> | ||
|
||
<script> | ||
const CLOSE_MODAL_DURATION = 500; | ||
|
||
const docRoot = document.demoShadowRoot || document; | ||
|
||
const showDialog = docRoot.querySelector('#showDialog'); | ||
|
||
let myTimeout; | ||
|
||
const layerHTML = ` | ||
<div class="layer" role="dialog"> | ||
<div class="layer-box"> | ||
<div class="panel panel-dialog danger m-0" role="dialog"> | ||
<div class="panel-body"> | ||
<div class="panel-content"> | ||
<div class="icogram"> | ||
<div | ||
class="icon far fa-question-circle scale300p" | ||
aria-hidden="true" | ||
aria-label="account" | ||
role="img" | ||
></div> | ||
<div class="text">Do you really want to delete XY?</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="panel-footer no-bg row justify-between center"> | ||
<div class="loose-button-group"> | ||
<button | ||
type="button" | ||
class="button transparent outline cancel" | ||
id="cancel" | ||
> | ||
<div class="icogram"> | ||
<span class="text">Cancel</span> | ||
</div> | ||
</button> | ||
<button type="button" class="button danger delete" id="delete"> | ||
<div class="icogram"> | ||
<span class="text">Delete</span> | ||
</div> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="layer-cover"></div> | ||
`; | ||
|
||
showDialog.addEventListener('click', () => { | ||
if (myTimeout) { | ||
clearTimeout(myTimeout); | ||
} | ||
|
||
showDialog.parentElement.insertAdjacentHTML('beforeend', layerHTML); | ||
|
||
const layerCover = docRoot.querySelector('.layer-cover'); | ||
const layer = docRoot.querySelector('.layer'); | ||
|
||
const cancelBtn = docRoot.querySelector('#cancel'); | ||
const deleteBtn = docRoot.querySelector('#delete'); | ||
|
||
// Listeners | ||
deleteBtn.addEventListener('click', () => { | ||
layerCover.classList.add('fade-out-animation'); | ||
layer.classList.add('fade-out-animation'); | ||
|
||
myTimeout = setTimeout(function () { | ||
layer.remove(); | ||
layerCover.remove(); | ||
}, CLOSE_MODAL_DURATION); | ||
}); | ||
|
||
cancelBtn.addEventListener('click', () => { | ||
layerCover.classList.add('fade-out-animation'); | ||
layer.classList.add('fade-out-animation'); | ||
|
||
myTimeout = setTimeout(() => { | ||
layer.remove(); | ||
layerCover.remove(); | ||
}, CLOSE_MODAL_DURATION); | ||
}); | ||
|
||
docRoot.onclick = (event) => { | ||
if (event.target === layerCover || event.target === layer) { | ||
layerCover.classList.add('fade-out-animation'); | ||
layer.classList.add('fade-out-animation'); | ||
|
||
myTimeout = setTimeout(() => { | ||
layer.remove(); | ||
layerCover.remove(); | ||
}, CLOSE_MODAL_DURATION); | ||
} | ||
}; | ||
}); | ||
</script> |
103 changes: 103 additions & 0 deletions
103
packages/vcl/layer/demo/example-with-zoom-animation.html
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,103 @@ | ||
<div class="example-layer-width-animation"> | ||
<button id="showDialog" type="button" class="button emphasized"> | ||
<div class="icogram"><span class="text">Show Dialog</span></div> | ||
</button> | ||
</div> | ||
|
||
<script> | ||
const CLOSE_MODAL_DURATION = 500; | ||
|
||
const docRoot = document.demoShadowRoot || document; | ||
|
||
const showDialog = docRoot.querySelector('#showDialog'); | ||
|
||
let myTimeout; | ||
|
||
const layerHTML = ` | ||
<div class="layer" role="dialog"> | ||
<div class="layer-box zoom"> | ||
<div class="panel panel-dialog danger m-0" role="dialog"> | ||
<div class="panel-body"> | ||
<div class="panel-content"> | ||
<div class="icogram"> | ||
<div | ||
class="icon far fa-question-circle scale300p" | ||
aria-hidden="true" | ||
aria-label="account" | ||
role="img" | ||
></div> | ||
<div class="text">Do you really want to delete XY?</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="panel-footer no-bg row justify-between center"> | ||
<div class="loose-button-group"> | ||
<button | ||
type="button" | ||
class="button transparent outline cancel" | ||
id="cancel" | ||
> | ||
<div class="icogram"> | ||
<span class="text">Cancel</span> | ||
</div> | ||
</button> | ||
<button type="button" class="button danger delete" id="delete"> | ||
<div class="icogram"> | ||
<span class="text">Delete</span> | ||
</div> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="layer-cover"></div> | ||
`; | ||
|
||
showDialog.addEventListener('click', () => { | ||
if (myTimeout) { | ||
clearTimeout(myTimeout); | ||
} | ||
|
||
showDialog.parentElement.insertAdjacentHTML('beforeend', layerHTML); | ||
|
||
const layerCover = docRoot.querySelector('.layer-cover'); | ||
const layer = docRoot.querySelector('.layer'); | ||
|
||
const cancelBtn = docRoot.querySelector('#cancel'); | ||
const deleteBtn = docRoot.querySelector('#delete'); | ||
|
||
// Listeners | ||
deleteBtn.addEventListener('click', () => { | ||
layerCover.classList.add('fade-out-animation'); | ||
layer.classList.add('fade-out-animation'); | ||
|
||
myTimeout = setTimeout(function () { | ||
layer.remove(); | ||
layerCover.remove(); | ||
}, CLOSE_MODAL_DURATION); | ||
}); | ||
|
||
cancelBtn.addEventListener('click', () => { | ||
layerCover.classList.add('fade-out-animation'); | ||
layer.classList.add('fade-out-animation'); | ||
|
||
myTimeout = setTimeout(() => { | ||
layer.remove(); | ||
layerCover.remove(); | ||
}, CLOSE_MODAL_DURATION); | ||
}); | ||
|
||
docRoot.onclick = (event) => { | ||
if (event.target === layerCover || event.target === layer) { | ||
layerCover.classList.add('fade-out-animation'); | ||
layer.classList.add('fade-out-animation'); | ||
|
||
myTimeout = setTimeout(() => { | ||
layer.remove(); | ||
layerCover.remove(); | ||
}, CLOSE_MODAL_DURATION); | ||
} | ||
}; | ||
}); | ||
</script> |
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