Skip to content

Commit

Permalink
fix #137
Browse files Browse the repository at this point in the history
  • Loading branch information
matt8707 committed Nov 27, 2022
1 parent 5d721da commit 30fc6cb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
33 changes: 33 additions & 0 deletions button_card_templates/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ base:
});
}
]]]
card_bounce: |
[[[
// duration
let duration = 800;
// animate
this.style.animation = `card_bounce ${duration}ms cubic-bezier(0.22, 1, 0.36, 1)`;
// reset
window.setTimeout(() => { this.style.animation = "none"; }, duration + 100)
// add animation
if (this.getElementsByTagName("style").length === 0) {
// phone condition
let mq = window.matchMedia('(max-width: 800px)').matches;
let style = document.createElement('style');
style.innerHTML = `
@keyframes card_bounce {
0% { transform: scale(1); }
10% { transform: scale(${mq ? "0.92" : "0.94"}); }
25% { transform: scale(1); }
30% { transform: scale(${mq ? "0.96" : "0.98"}); }
100% { transform: scale(1); }
}
`;
this.appendChild(style);
}
]]]
action: toggle
haptic: medium
double_tap_action:
Expand All @@ -66,6 +98,7 @@ base:
- grid-template-rows: auto repeat(2, min-content)
- gap: 1.3%
- align-items: start
- will-change: transform
name:
- justify-self: start
- line-height: 121%
Expand Down
21 changes: 3 additions & 18 deletions button_card_templates/loader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,9 @@ loader:
custom_fields:
loader:
- display: none
- top: >
[[[
return variables.tilt_enable
? '-6%'
: '6%';
]]]
- right: >
[[[
return variables.tilt_enable
? '-3.5%'
: '6.5%';
]]]
- width: >
[[[
return variables.tilt_enable
? '52%'
: '42%';
]]]
- top: -6%
- right: -3.5%
- width: 52%
- position: absolute
- opacity: 0.5
- pointer-events: none
Expand Down

4 comments on commit 30fc6cb

@lichenophile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to add an unnecessary loader animation to my light entities, as they happen to be basically instantaneous.

Could there be a way for me to disable the loader on specific entities?

Or, in case of communication lag, only show if state update doesn't happen within 500ms or similar?

@matt8707
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't add any loaders though?
remove this line

@lichenophile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea sorry, I'm an idiot. I could have sworn it just started happening, but clearly unrelated either way.

@matt8707
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, in case of communication lag, only show if state update doesn't happen within 500ms or similar?

I like this idea 👍

Please sign in to comment.