Skip to content

Commit

Permalink
Do not move shutter when updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Deejayfool committed Jun 22, 2020
1 parent c04e2cd commit 8891a0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions hass-shutter-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class ShutterCard extends HTMLElement {
event.preventDefault();
}

_this.isUpdating = true;

document.addEventListener('mousemove', mouseMove);
document.addEventListener('touchmove', mouseMove);
document.addEventListener('pointermove', mouseMove);
Expand All @@ -93,6 +95,8 @@ class ShutterCard extends HTMLElement {
};

let mouseUp = function(event) {
_this.isUpdating = false;

let newPosition = event.pageY - _this.getPictureTop(picture);

if (newPosition < _this.minPosition)
Expand Down Expand Up @@ -192,10 +196,13 @@ class ShutterCard extends HTMLElement {
shutter.querySelectorAll('.sc-shutter-label').forEach(function(shutterLabel) {
shutterLabel.innerHTML = friendlyName;
})
shutter.querySelectorAll('.sc-shutter-position').forEach(function (shutterPosition) {

if (!_this.isUpdating) {
shutter.querySelectorAll('.sc-shutter-position').forEach(function (shutterPosition) {
shutterPosition.innerHTML = currentPosition + '%';
})
_this.setPickerPositionPercentage(100 - currentPosition, picker, slide);
})
_this.setPickerPositionPercentage(100 - currentPosition, picker, slide);
}
});
}

Expand Down Expand Up @@ -247,6 +254,7 @@ class ShutterCard extends HTMLElement {
this.config = config;
this.maxPosition = 137;
this.minPosition = 19;
this.isUpdating = false;
}

// The height of your card. Home Assistant uses this to automatically
Expand Down
Binary file modified images/shutter-card.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8891a0b

Please sign in to comment.