Skip to content

Commit 676a5e7

Browse files
authored
fix(pet): draw the egg without a clipPath so old iPads don't freeze (#1115)
1 parent 99a9f97 commit 676a5e7

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎custom_components/taskmate/www/taskmate-pet-card.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ function petAnchors(species, stage) {
8888

8989
const f = (n) => Math.round(n * 10) / 10;
9090

91+
// The egg is drawn without a <clipPath>: on iOS 15 Safari a clip inside the
92+
// wobbling .tm-pet group froze the whole page (#1113). The spots all sit well
93+
// inside the shell, and the shading is a crescent cut to the egg's edge.
9194
function egg(species) {
9295
const p = PET_PALETTES[species];
9396
const spots = {
@@ -100,9 +103,9 @@ function egg(species) {
100103
}[species];
101104
return `
102105
<ellipse cx="100" cy="188" rx="46" ry="7" fill="#000" opacity=".12"/>
103-
<clipPath id="tm-egg-${species}"><path d="M100 46 C140 46 152 112 152 136 C152 166 128 186 100 186 C72 186 48 166 48 136 C48 112 60 46 100 46Z"/></clipPath>
104106
<path d="M100 46 C140 46 152 112 152 136 C152 166 128 186 100 186 C72 186 48 166 48 136 C48 112 60 46 100 46Z" fill="${p.body}"/>
105-
<g clip-path="url(#tm-egg-${species})">${spots}<ellipse cx="128" cy="150" rx="40" ry="44" fill="${p.shade}" opacity=".35"/></g>
107+
${spots}
108+
<path d="M149.7 113.1 C151.3 122.1 152 130.3 152 136 C152 164.3 130.7 183.7 104.8 185.8 A40 44 0 0 1 149.7 113.1Z" fill="${p.shade}" opacity=".35"/>
106109
<ellipse cx="80" cy="84" rx="9" ry="15" fill="#fff" opacity=".55" transform="rotate(-20 80 84)"/>
107110
<path d="M100 46 C140 46 152 112 152 136 C152 166 128 186 100 186 C72 186 48 166 48 136 C48 112 60 46 100 46Z" fill="none" stroke="${p.line}" stroke-width="5"/>`;
108111
}

‎tests/frontend/taskmate-raffle-pet-kiosk.test.cjs‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,23 @@ for (const design of DESIGNS) {
171171

172172
test("pet: an egg is an egg, a grown pet with nothing switched on says so", () => {
173173
const egg = render(petCard({ adopted: true, name: "E", species: "cat", stage: "egg", chores: 0, xp: 0, goal: { kind: "stage", from: 0, at: 30 }, mood: "happy", accessories: [] }).card.render()).markup;
174-
assert.match(egg, /tm-egg-cat/);
174+
assert.match(egg, /class="pt-stage[^"]*stage-egg/);
175+
assert.match(egg, /#f39b3d/, "the cat egg's shell colour");
175176
const grown = render(petCard({ adopted: true, name: "G", species: "dog", stage: "grown", chores: 120, xp: 1700, mood: "proud", accessories: ["bow", "top_hat", "scarf", "crown"] }).card.render()).markup;
176177
assert.ok(grown.includes(localize("pet.fully_grown", { name: "G" })));
177178
assert.match(grown, /👑/);
178179
assert.doesNotMatch(grown, /role="progressbar"/);
179180
});
180181

182+
test("pet: the egg has no clipPath, which froze iOS 15 Safari inside the wobble (#1113)", () => {
183+
const { petScene, petArt } = (petMod.window ? petMod.window.__taskmate_pet_art : sandbox.window?.__taskmate_pet_art) || {};
184+
for (const species of ["dragon", "cat", "dog", "bunny", "dino", "unicorn"]) {
185+
for (const markup of [petScene(species, "egg"), petArt(species, "egg")]) {
186+
assert.doesNotMatch(markup, /clipPath|clip-path/, species);
187+
}
188+
}
189+
});
190+
181191
test("pet: each stage looks different, and legendary turns it gold", () => {
182192
const art = petMod.window ? petMod.window.__taskmate_pet_art : sandbox.window?.__taskmate_pet_art;
183193
const { petArt } = art || {};

0 commit comments

Comments
 (0)