Browse Source

Some tweaks in snapping dragged items to nice dates.

css_transitions
jos 10 years ago
parent
commit
36ff1f5b64
2 changed files with 21 additions and 4 deletions
  1. +7
    -2
      HISTORY.md
  2. +14
    -2
      src/timeline/TimeStep.js

+ 7
- 2
HISTORY.md View File

@ -2,11 +2,16 @@
http://visjs.org http://visjs.org
## 2014-05-09, version 1.0.2
## not yet released, version 1.0.2
### Timeline
- Some tweaks in snapping dragged items to nice dates.
### Graph ### Graph
- changes setOptions to avoid resetting view.
- Changes setOptions to avoid resetting view.
## 2014-05-09, version 1.0.1 ## 2014-05-09, version 1.0.1

+ 14
- 2
src/timeline/TimeStep.js View File

@ -314,8 +314,7 @@ TimeStep.prototype.snap = function(date) {
clone.setSeconds(0); clone.setSeconds(0);
clone.setMilliseconds(0); clone.setMilliseconds(0);
} }
else if (this.scale == TimeStep.SCALE.DAY ||
this.scale == TimeStep.SCALE.WEEKDAY) {
else if (this.scale == TimeStep.SCALE.DAY) {
//noinspection FallthroughInSwitchStatementJS //noinspection FallthroughInSwitchStatementJS
switch (this.step) { switch (this.step) {
case 5: case 5:
@ -328,6 +327,19 @@ TimeStep.prototype.snap = function(date) {
clone.setSeconds(0); clone.setSeconds(0);
clone.setMilliseconds(0); clone.setMilliseconds(0);
} }
else if (this.scale == TimeStep.SCALE.WEEKDAY) {
//noinspection FallthroughInSwitchStatementJS
switch (this.step) {
case 5:
case 2:
clone.setHours(Math.round(clone.getHours() / 12) * 12); break;
default:
clone.setHours(Math.round(clone.getHours() / 6) * 6); break;
}
clone.setMinutes(0);
clone.setSeconds(0);
clone.setMilliseconds(0);
}
else if (this.scale == TimeStep.SCALE.HOUR) { else if (this.scale == TimeStep.SCALE.HOUR) {
switch (this.step) { switch (this.step) {
case 4: case 4:

Loading…
Cancel
Save