Skip to content

Commit

Permalink
Make docking window dock at bottom by default
Browse files Browse the repository at this point in the history
  • Loading branch information
zz85 committed May 18, 2020
1 parent 4ba6fcd commit 7946113
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ or
1. Select time between 2 keyframes
2. Select easing type from the dropdown

### Development

To test without compiling, open test_module.html in the browser.

Format code

```
yarn run fix
```

Generate Build

```
yarn run mini
```


## Releases

1.5.0
Expand Down
15 changes: 1 addition & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
/*
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'src/timeliner.js',
output: {
dir: 'build',
format: 'cjs'
},
plugins: [commonjs()]
};
*/

import { terser } from "rollup-plugin-terser";
simport { terser } from "rollup-plugin-terser";

This comment has been minimized.

Copy link
@TaeKyuzzzz

TaeKyuzzzz Apr 11, 2023

what is simport? i think this might be a typo


export default {
input: 'src/timeliner.js',
Expand Down
52 changes: 33 additions & 19 deletions src/utils/docking_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const SNAP_TOP_EDGE = 'snap-top-edge' // or actually top half
const SNAP_LEFT_EDGE = 'snap-left-edge'
const SNAP_RIGHT_EDGE = 'snap-right-edge'
const SNAP_BOTTOM_EDGE = 'snap-bottom-edge'
const SNAP_DOCK_BOTTOM = 'dock-bottom'

function setBounds(element, x, y, w, h) {
element.style.left = x + 'px';
Expand Down Expand Up @@ -108,30 +109,13 @@ function DockingWindow(pane, ghostpane) {

this.resizes = new Do();

window.addEventListener('resize', function() {
resizeEdges();
});

/* DOM Utils */
function hideGhostPane() {
// hide the hinter, animatating to the pane's bounds
setBounds(ghostpane, bounds.left, bounds.top, bounds.width, bounds.height);
ghostpane.style.opacity = 0;
}

setBounds(pane, 0, 0, LayoutConstants.width, LayoutConstants.height);
setBounds(ghostpane, 0, 0, LayoutConstants.width, LayoutConstants.height);

// Mouse events
pane.addEventListener('mousedown', onMouseDown);
document.addEventListener('mousemove', onMove);
document.addEventListener('mouseup', onMouseUp);

// Touch events
pane.addEventListener('touchstart', onTouchDown);
document.addEventListener('touchmove', onTouchMove);
document.addEventListener('touchend', onTouchEnd);

function onTouchDown(e) {
onDown(e.touches[0]);
e.preventDefault();
Expand Down Expand Up @@ -304,8 +288,6 @@ function DockingWindow(pane, ghostpane) {

}

animate();

var self = this;

var snapBounds = {}
Expand Down Expand Up @@ -346,6 +328,11 @@ function DockingWindow(pane, ghostpane) {
left = 0
top = window.innerHeight - height
break;
case SNAP_DOCK_BOTTOM:
width = bounds.width
height = bounds.height
left = (window.innerWidth - width) * 0.5
top = window.innerHeight - height
}

Object.assign(snapBounds, { left, top, width, height });
Expand Down Expand Up @@ -385,6 +372,33 @@ function DockingWindow(pane, ghostpane) {

pointerStart = null;
}

function init() {
window.addEventListener('resize', function() {
resizeEdges();
});

setBounds(pane, 0, 0, LayoutConstants.width, LayoutConstants.height);
setBounds(ghostpane, 0, 0, LayoutConstants.width, LayoutConstants.height);

// Mouse events
pane.addEventListener('mousedown', onMouseDown);
document.addEventListener('mousemove', onMove);
document.addEventListener('mouseup', onMouseUp);

// Touch events
pane.addEventListener('touchstart', onTouchDown);
document.addEventListener('touchmove', onTouchMove);
document.addEventListener('touchend', onTouchEnd);

bounds = pane.getBoundingClientRect();
snapType = SNAP_DOCK_BOTTOM
resizeEdges();

animate();
}

init();
}


Expand Down

0 comments on commit 7946113

Please sign in to comment.