chrome style fix + improv animations + hover interactions

This commit is contained in:
JoanaChicau 2021-03-10 19:01:42 +01:00
parent d7fa536c82
commit 3e508fd3a9
2 changed files with 82 additions and 82 deletions

View File

@ -8,6 +8,7 @@
</head>
<body>
<div class="about"><a href="https://vvvvvvaria.org/logs/narrowcast/" target="_blank">back<span></span><br>↬ stage </a></div>
<div id="side" class="sidebar sidemin">
@ -76,79 +77,75 @@
-->
<p class="note"> * move and resize the elements above by dragging their corners and sides *</p>
<p class="note"> * move and resize the elements above by dragging their corners / sides and click on the page to set the position *</p>
</div>
</div>
<!-- button to hide side pannel -->
<!-- BBUTTON HIDE side pannel -->
<script type="text/javascript">
<script type="text/javascript">
function fside() {
var element = document.getElementById("side");
element.classList.toggle("sideminclicked");
}
</script>
function fside() {
var element = document.getElementById("side");
element.classList.toggle("sideminclicked");
}
</script>
<!-- drag and resize library: https://interactjs.io/docs/installation#cdn-streamlined -->
<script src="interact.min.js"></script>
<!-- script above same as <script src="https://cdnjs.cloudflare.com/ajax/libs/interact.js/1.2.6/interact.min.js"></script> -->
<!-- also found this other options:
https://www.webcomponents.org/element/jifalops/drag-resize
https://codepen.io/zz85/pen/gbOoVP -->
<!-- DRAG and RESIZE library -->
<script>
interact('.resize-drag')
.draggable({
onmove: window.dragMoveListener
})
.resizable({
preserveAspectRatio: true,
edges: { left: true, right: true, bottom: true, top: true }
})
.on('resizemove', function (event) {
var target = event.target,
x = (parseFloat(target.getAttribute('data-x')) || 0),
y = (parseFloat(target.getAttribute('data-y')) || 0);
<!-- source: https://interactjs.io/docs/installation#cdn-streamlined -->
<script src="interact.min.js"></script>
<!-- script above same as https://cdnjs.cloudflare.com/ajax/libs/interact.js/1.2.6/interact.min.js -->
// update the element's style
target.style.width = event.rect.width + 'px';
target.style.height = event.rect.height + 'px';
<!-- also found this other options:
https://www.webcomponents.org/element/jifalops/drag-resize
https://codepen.io/zz85/pen/gbOoVP -->
// translate when resizing from top or left edges
x += event.deltaRect.left;
y += event.deltaRect.top;
<script>
interact('.resize-drag')
.draggable({
onmove: window.dragMoveListener
})
.resizable({
preserveAspectRatio: true,
edges: { left: true, right: true, bottom: true, top: true }
})
.on('resizemove', function (event) {
var target = event.target,
x = (parseFloat(target.getAttribute('data-x')) || 0),
y = (parseFloat(target.getAttribute('data-y')) || 0);
target.style.webkitTransform = target.style.transform =
'translate(' + x + 'px,' + y + 'px)';
// update the element's style
target.style.width = event.rect.width + 'px';
target.style.height = event.rect.height + 'px';
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
target.textContent = event.rect.width + '×' + event.rect.height;
});
// translate when resizing from top or left edges
x += event.deltaRect.left;
y += event.deltaRect.top;
function dragMoveListener (event) {
var target = event.target,
// keep the dragged position in the data-x/data-y attributes
x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
target.style.webkitTransform = target.style.transform =
'translate(' + x + 'px,' + y + 'px)';
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
target.textContent = event.rect.width + '×' + event.rect.height;
});
function dragMoveListener (event) {
var target = event.target,
// keep the dragged position in the data-x/data-y attributes
x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
// update the posiion attributes
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
}
</script>
// update the posiion attributes
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
}
</script>
</body>

View File

@ -124,7 +124,7 @@ button.minimize{
.sidetop {
height: 45vh;
font-size: 1.2rem;
justify-content: end;
justify-content: flex-end;
}
.sidetop p {
@ -191,12 +191,12 @@ button.minimize{
.resize-drag {
width: 620px;
padding: 1.4rem 0.4rem 0.4rem 1.4rem;
padding: 0.4rem 1.8rem 1.8rem 0.4rem;
margin: 1rem;
touch-action: none;
/* This makes things *much* easier */
box-sizing: border-box;
box-shadow: inset 0.6rem 0.2rem 0.9rem #ffe4fd;
box-shadow: inset -0.6rem 0rem 0.8rem #ffe4fd;
border-radius: 0.1rem 0.1rem 0.2rem 0.1rem;
position: relative;
}
.drag::before, .resize-drag::before, .live > *::before {
@ -208,11 +208,12 @@ button.minimize{
position: absolute !important;
z-index: 999;
top: 0;
left: 0;
display: block;
left: 0;
display: block;
}
.resize-drag {
.resize-drag:hover {
box-shadow: 0.2rem 0.2rem 0.6rem #ffe4fd;
animation: corners 8s infinite alternate;
-o-animation: corners 8s infinite alternate;
-moz-animation: corners 8s infinite alternate;
@ -221,29 +222,31 @@ button.minimize{
@keyframes corners {
0% {
border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
-webkit-border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
border-radius: 0.1rem 0.1rem 0.2rem 0.1rem;
-webkit-border-radius: 0.1rem 0.1rem 0.2rem 0.1rem;
}
70% {
border-radius: 2rem 0rem 1rem 2rem;
-webkit-border-radius: 2rem 0rem 1rem 2rem;
}
100% {
20% {
border-radius: 0rem 4rem 2rem 1rem / 0rem 1rem 2rem 0rem;
-webkit-border-radius: 0rem 4rem 2rem 1rem / 0rem 1rem 2rem 0rem; }
@-webkit-keyframes corners {
0% {
border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
-webkit-border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
}
70% {
border-radius: 2rem 0rem 1rem 2rem;
-webkit-border-radius: 2rem 0rem 1rem 2rem;
}
100% {
border-radius: 0rem 4rem 2rem 1rem / 0rem 1rem 2rem 0rem;
-webkit-border-radius: 0rem 4rem 2rem 1rem / 0rem 1rem 2rem 0rem;
}
100% {
border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
-webkit-border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
}
}
@-webkit-keyframes corners {
0% {
border-radius: 2rem 0rem 1rem 2rem;
-webkit-border-radius: 2rem 0rem 1rem 2rem;
}
20% {
border-radius: 0rem 4rem 2rem 1rem / 0rem 1rem 2rem 0rem;
-webkit-border-radius: 0rem 4rem 2rem 1rem / 0rem 1rem 2rem 0rem;
}
100% {
border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
-webkit-border-radius: 1% 0% 0% 0% / 45% 0% 0% 0%;
}
}