Skip to content

Commit 51e968d

Browse files
authored
ref(animation): update method (#42)
1 parent 94fcaa7 commit 51e968d

File tree

5 files changed

+290
-164
lines changed

5 files changed

+290
-164
lines changed

demo/src/app/index/pages/segment/segment.page.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, ElementRef, inject, OnInit } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { FormsModule } from '@angular/forms';
44
import {
5+
Gesture,
56
IonBackButton,
67
IonButton,
78
IonButtons,
@@ -16,7 +17,10 @@ import {
1617
IonSegmentButton,
1718
IonText,
1819
IonToolbar,
20+
ViewDidEnter,
21+
ViewDidLeave,
1922
} from '@ionic/angular/standalone';
23+
import { registeredEffect, registerSegmentEffect, registerTabBarEffect } from '../../../../../../src';
2024

2125
@Component({
2226
selector: 'app-segment',
@@ -42,8 +46,23 @@ import {
4246
IonButton,
4347
],
4448
})
45-
export class SegmentPage implements OnInit {
49+
export class SegmentPage implements OnInit, ViewDidEnter, ViewDidLeave {
50+
readonly #el = inject(ElementRef);
51+
readonly registeredGestures: registeredEffect[] = [];
4652
constructor() {}
4753

4854
ngOnInit() {}
55+
56+
ionViewDidEnter() {
57+
this.#el.nativeElement.querySelectorAll('ion-segment').forEach((item: HTMLElement) => {
58+
const registerGesture = registerSegmentEffect(item);
59+
if (registerGesture) {
60+
this.registeredGestures.push(registerGesture);
61+
}
62+
});
63+
}
64+
65+
ionViewDidLeave() {
66+
this.registeredGestures.forEach((gesture) => gesture.destroy());
67+
}
4968
}

demo/src/app/tabs/tabs.page.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { NavigationEnd, Router } from '@angular/router';
44
import { filter } from 'rxjs';
55

66
// import { registerTabBarEffect } from '@rdlabo/ionic-theme-ios26';
7-
import { registerTabBarEffect } from '../../../../src';
7+
import { registeredEffect, registerTabBarEffect } from '../../../../src';
88

99
@Component({
1010
selector: 'app-tabs',
@@ -15,7 +15,7 @@ import { registerTabBarEffect } from '../../../../src';
1515
export class TabsPage implements OnInit, ViewDidEnter, ViewDidLeave {
1616
readonly #router = inject(Router);
1717
readonly #el = inject(ElementRef);
18-
readonly registeredGestures: Gesture[] = [];
18+
readonly registeredGestures: registeredEffect[] = [];
1919
ngOnInit() {
2020
this.#router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe((params) => {
2121
const tabBar = this.#el.nativeElement.querySelector('ion-tab-bar');
@@ -31,9 +31,9 @@ export class TabsPage implements OnInit, ViewDidEnter, ViewDidLeave {
3131
}
3232

3333
ionViewDidEnter() {
34-
const tabBarGesture = registerTabBarEffect(document.querySelector<HTMLElement>('ion-tab-bar')!);
35-
if (tabBarGesture) {
36-
this.registeredGestures.push();
34+
const registerGesture = registerTabBarEffect(document.querySelector<HTMLElement>('ion-tab-bar')!);
35+
if (registerGesture) {
36+
this.registeredGestures.push(registerGesture);
3737
}
3838
}
3939

src/components/ion-segment.scss

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,7 @@ ion-segment.ios:not(.ios26-disabled) {
2727
}
2828
}
2929

30-
ion-segment-button {
31-
--border-width: 0;
32-
--ion-color-base: var(--ion-text-color, #000);
33-
--padding-start: 8px;
34-
--padding-end: 8px;
35-
min-width: 60px;
36-
margin: 3px 2px;
37-
font-size: 14.5px;
38-
39-
&::part(indicator-background) {
40-
border-radius: 25px;
41-
box-shadow: none;
42-
transition: background 0.2s ease;
43-
background: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.06);
44-
}
45-
}
46-
47-
&.segment-activated {
30+
&:has(ion-segment-button.ion-activated) {
4831
transform: scale(1.1);
4932

5033
ion-segment-button {
@@ -62,3 +45,38 @@ ion-segment.ios:not(.ios26-disabled) {
6245
}
6346
}
6447
}
48+
49+
ion-segment-button.ios:not(.ios26-disabled) {
50+
--border-width: 0;
51+
--ion-color-base: var(--ion-text-color, #000);
52+
--padding-start: 8px;
53+
--padding-end: 8px;
54+
min-width: 60px;
55+
margin: 3px 2px;
56+
font-size: 14.5px;
57+
58+
&::part(indicator-background) {
59+
border-radius: 25px;
60+
box-shadow: none;
61+
transition: background 0.2s ease;
62+
background: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.06);
63+
}
64+
65+
&.ion-cloned-element {
66+
&::part(native) {
67+
border-radius: 25px;
68+
@include api.glass-background(1, 0, 104%);
69+
background: transparent;
70+
height: 100%;
71+
}
72+
color: var(--color-selected, var(--ion-color-primary, #0054e9));
73+
pointer-events: none;
74+
position: absolute;
75+
left: 0;
76+
top: -2.5px;
77+
transform-origin: center;
78+
& > * {
79+
visibility: hidden;
80+
}
81+
}
82+
}

src/components/ion-tabs.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ion-tab-bar.ios:not(.ios26-disabled) {
4646
/**
4747
* effectが有効な場合、effectでスタイリングするため不要
4848
*/
49-
&.tab-bar-ios26-effect:has(ion-tab-button.ion-activated) {
49+
&.enable-ios26-gesture:has(ion-tab-button.ion-activated) {
5050
ion-tab-button.tab-selected::part(native) {
5151
background: rgba(var(--ios26-button-color-selected-rgb), 0);
5252
}
@@ -101,7 +101,7 @@ ion-tab-button.ios:not(.ios26-disabled) {
101101

102102
&.ion-cloned-element {
103103
&::part(native) {
104-
@include api.glass-background(1, 2px, 104%);
104+
@include api.glass-background(1, 0, 104%);
105105
background: transparent;
106106
}
107107
color: var(--color-selected, var(--ion-color-primary, #0054e9));

0 commit comments

Comments
 (0)