Skip to content

Commit

Permalink
Attached listener higher up
Browse files Browse the repository at this point in the history
  • Loading branch information
psy-q committed Sep 5, 2019
1 parent 1a35909 commit e45351b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions Assets/scroll.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
KB.on('dom.ready', function () {
function attachHorizontalScrollListeners() {
var boardContainer = $('#board-container');
var mainContainer = $('#main');
let isDown = false;
let startX;
let scrollLeftPixels;

boardContainer.on('mousedown', (e) => {
mainContainer.on('mousedown', (e) => {
isDown = true;
boardContainer.addClass('horizontally-dragged');
startX = e.pageX - boardContainer.offset().left;
scrollLeftPixels = boardContainer.scrollLeft();
$('#board-container').addClass('horizontally-dragged');
startX = e.pageX - $('#board-container').offset().left;
scrollLeftPixels = $('#board-container').scrollLeft();
});

boardContainer.on('mouseleave', () => {
mainContainer.on('mouseleave', () => {
isDown = false;
boardContainer.removeClass('horizontally-dragged');
$('#board-container').removeClass('horizontally-dragged');
});

boardContainer.on('mouseup', () => {
mainContainer.on('mouseup', () => {
isDown = false;
boardContainer.removeClass('horizontally-dragged');
$('#board-container').removeClass('horizontally-dragged');
});

boardContainer.on('mousemove', (e) => {
mainContainer.on('mousemove', (e) => {
if (!isDown) return;
// This is a draggable card, we don't want to also drag the background while
// dragging a card.
if ($(e.target).parents('div.task-board.draggable-item').length != 0) return;
e.preventDefault();
const x = e.pageX - boardContainer.offset().left;
const x = e.pageX - $('#board-container').offset().left;
const walk = (x - startX) * 2; // Scroll speed
boardContainer.scrollLeft(scrollLeftPixels - walk);
$('#board-container').scrollLeft(scrollLeftPixels - walk);
});
}

Expand Down
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '0.0.1';
return '0.1.0';
}

public function getPluginHomepage()
Expand Down

0 comments on commit e45351b

Please sign in to comment.