Skip to content

Commit

Permalink
Add drag and drop support
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Oct 10, 2014
1 parent 3e6d6cb commit 0e89cfa
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
28 changes: 28 additions & 0 deletions template/assets/markline/0.5.3/markline-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,34 @@ define("markline/0.5.3/timeline-debug", ["jquery/2.1.1/jquery-debug"], function(
this._element.append(['<header>', this.title, '</header>'].join(""));
this._element.append(head_dates.join(""));
this._element.append(body_events.join(""));
// scroll via mouse drag and drop.
var startingMousePostition;
var startingPagePosition;
this._element.on('mousedown', function(event) {
startingMousePostition = {
x: event.clientX,
y: event.clientY
};
startingPagePosition = {
x: me._element.scrollLeft(),
y: me._element.scrollTop()
};
console.log(startingPagePosition)
console.log(startingMousePostition)
me._element.on('mousemove', drag);
});
this._element.on('mouseup', function(event) {
me._element.off('mousemove', drag);
});

function drag(event) {
event.preventDefault();
var x = startingPagePosition.x + (startingMousePostition.x - event.clientX);
var y = startingPagePosition.y + (startingMousePostition.y - event.clientY);
console.log("D", x, y)
me._element.scrollLeft(x);
me._element.scrollTop(y);
}
};
module.exports = Markline;
});
2 changes: 1 addition & 1 deletion template/assets/markline/0.5.3/markline.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions template/assets/markline/0.5.3/timeline-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,34 @@ define("markline/0.5.3/timeline-debug", ["jquery/2.1.1/jquery-debug"], function(
this._element.append(['<header>', this.title, '</header>'].join(""));
this._element.append(head_dates.join(""));
this._element.append(body_events.join(""));
// scroll via mouse drag and drop.
var startingMousePostition;
var startingPagePosition;
this._element.on('mousedown', function(event) {
startingMousePostition = {
x: event.clientX,
y: event.clientY
};
startingPagePosition = {
x: me._element.scrollLeft(),
y: me._element.scrollTop()
};
console.log(startingPagePosition)
console.log(startingMousePostition)
me._element.on('mousemove', drag);
});
this._element.on('mouseup', function(event) {
me._element.off('mousemove', drag);
});

function drag(event) {
event.preventDefault();
var x = startingPagePosition.x + (startingMousePostition.x - event.clientX);
var y = startingPagePosition.y + (startingMousePostition.y - event.clientY);
console.log("D", x, y)
me._element.scrollLeft(x);
me._element.scrollTop(y);
}
};
module.exports = Markline;
});
2 changes: 1 addition & 1 deletion template/assets/markline/0.5.3/timeline.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,38 @@ Markline.prototype.render = function(){
this._element.append(head_dates.join(""));
this._element.append(body_events.join(""));


// scroll via mouse drag and drop.
var startingMousePostition;
var startingPagePosition;
this._element.on('mousedown', function(event){
startingMousePostition = {
x: event.clientX,
y: event.clientY
};
startingPagePosition = {
x: me._element.scrollLeft(),
y: me._element.scrollTop()
};

console.log(startingPagePosition)
console.log(startingMousePostition)
me._element.on('mousemove', drag);
});
this._element.on('mouseup', function(event){
me._element.off('mousemove', drag);
});

function drag(event){
event.preventDefault();
var x = startingPagePosition.x + (startingMousePostition.x - event.clientX);
var y = startingPagePosition.y + (startingMousePostition.y - event.clientY);
console.log("D", x, y)
me._element.scrollLeft(x);
me._element.scrollTop(y);
}
};



module.exports = Markline;

0 comments on commit 0e89cfa

Please sign in to comment.