Skip to content

Commit

Permalink
2.0.3 (#208)
Browse files Browse the repository at this point in the history
* Fixes #206, Fixes #195 (#207)

* Fixes #206

* Return original value if !value in _getTemplateOrValue

* Fixes #195 IOS 13 tap behaviour

* Bump patch version
  • Loading branch information
RomRider authored Jul 29, 2019
1 parent 62b648e commit cac0ccc
Show file tree
Hide file tree
Showing 7 changed files with 942 additions and 396 deletions.
1,247 changes: 856 additions & 391 deletions dist/button-card.js

Large diffs are not rendered by default.

61 changes: 60 additions & 1 deletion package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "button-card",
"version": "2.0.2",
"version": "2.0.3",
"description": "Button card for lovelace",
"main": "dist/button-card.js",
"pre-commit": [
Expand Down Expand Up @@ -46,6 +46,7 @@
"prettier": "^1.18.2",
"rollup": "^1.17.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^4.2.4",
"rollup-plugin-terser": "^4.0.4",
Expand All @@ -56,6 +57,7 @@
},
"dependencies": {
"@ctrl/tinycolor": "^2.5.3",
"bowser": "^2.5.2",
"custom-card-helpers": "^1.2.2",
"home-assistant-js-websocket": "^3.4.0",
"lit-element": "^2.2.0",
Expand Down
4 changes: 4 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
Expand All @@ -13,6 +14,9 @@ export default {
},
plugins: [
resolve(),
commonjs({
namedExports: { bowser: ['getParser'] },
}),
typescript(),
json(),
babel({
Expand Down
4 changes: 4 additions & 0 deletions rollup.debug.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
Expand All @@ -12,6 +13,9 @@ export default {
},
plugins: [
resolve(),
commonjs({
namedExports: { bowser: ['getParser'] },
}),
typescript(),
json(),
babel({
Expand Down
5 changes: 4 additions & 1 deletion src/button-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class ButtonCard extends LitElement {
value: any | undefined,
): any | undefined {
if (['number', 'boolean'].includes(typeof value)) return value;
if (!value) return undefined;
if (!value) return value;
const trimmed = value.trim();
if (
trimmed.substring(0, 3) === '[[['
Expand Down Expand Up @@ -796,6 +796,9 @@ class ButtonCard extends LitElement {
const configDuplicate = JSON.parse(JSON.stringify(config));
/* eslint no-param-reassign: 0 */
const __evalObject = (configEval: any): any => {
if (!configEval) {
return configEval;
}
Object.keys(configEval).forEach((key) => {
if (typeof configEval[key] === 'object') {
configEval[key] = __evalObject(configEval[key]);
Expand Down
13 changes: 11 additions & 2 deletions src/long-press.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { directive, PropertyPart } from 'lit-html';
import * as Bowser from 'bowser';
// See https://github.com/home-assistant/home-assistant-polymer/pull/2457
// on how to undo mwc -> paper migration
// import '@material/mwc-ripple';
Expand Down Expand Up @@ -179,11 +180,19 @@ class LongPress extends HTMLElement implements LongPress {
window.setTimeout(() => (this.cooldownEnd = false), 100);
};

const br = Bowser.getParser(window.navigator.userAgent);
const isCrazyBrowser = br.satisfies({
mobile: {
safari: '>=13',
},
});
element.addEventListener('touchstart', clickStart, { passive: true });
element.addEventListener('touchend', clickEnd);
element.addEventListener('touchcancel', clickEnd);
element.addEventListener('mousedown', clickStart, { passive: true });
element.addEventListener('click', clickEnd);
if (!isCrazyBrowser) {
element.addEventListener('mousedown', clickStart, { passive: true });
element.addEventListener('click', clickEnd);
}
}

private startAnimation(x: number, y: number) {
Expand Down

0 comments on commit cac0ccc

Please sign in to comment.