Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] ripples: dynamically enable/disable all interaction ripples #9729

Closed
reppners opened this issue Feb 1, 2018 · 3 comments · Fixed by #14705
Closed

[feat] ripples: dynamically enable/disable all interaction ripples #9729

reppners opened this issue Feb 1, 2018 · 3 comments · Fixed by #14705
Assignees
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@reppners
Copy link

reppners commented Feb 1, 2018

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

Enable/Disable ripples globally at runtime.

What is the current behavior?

Ripples can be disabled globally by providing MAT_RIPPLE_GLOBAL_OPTIONS.

This is static and can't be changed at runtime.
If this assumption is wrong please show me how to dynamically change the root injectors value.

What is the use-case or motivation for changing an existing behavior?

An app that needs to run on low-end-devices as well as high-end devices. The user has the ability to disable styles and effects that degrade performance on low-end devices. This includes disabling ripples.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.6.6
Node: 6.11.4
OS: darwin x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

@angular/cdk: 5.1.1
@angular/cli: 1.6.6
@angular/flex-layout: 2.0.0-beta.12
@angular/material: 5.1.1
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.24
@angular-devkit/schematics: 0.0.43
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.6.2
webpack-bundle-analyzer: 2.9.1
webpack: 3.10.0

@reppners
Copy link
Author

reppners commented Feb 1, 2018

Quick follow up:

I applied the workaround mentioned in #8298 (comment)

.mat-ripple-element {
    transition-duration: 0ms !important;
}

Which already improves performance on low-end devices. I like that it still highlights something the user touches which is a lot better than having no feedback at all just because of performance issues.

Maybe the workaround is suitable as an "official" low-performance device workaround?

@jelbourn jelbourn added feature This issue represents a new feature or feature request rather than a bug or bug fix P5 The team acknowledges the request but does not plan to address it, it remains open for discussion discussion labels Feb 13, 2018
@devversion devversion self-assigned this Jul 3, 2018
@devversion
Copy link
Member

Dynamically modifying the global ripple options is already partially working (except for chips & tab-nav-bar).

app.module.ts

@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MyMaterialModule,
  ],
  declarations: [HomeComponent],
  bootstrap: [HomeComponent],
  providers: [
    // Alias the ripple global options to an existing provider instance (singleton; at root)
    { provide: MAT_RIPPLE_GLOBAL_OPTIONS, useExisting: AppRippleOptions }
  ]
})
export class AppModule {}

app-ripple-options.ts

import {RippleGlobalOptions, RippleAnimationConfig} from '@angular/material';
import {Injectable} from '@angular/core';

@Injectable({providedIn: 'root'})
export class AppRippleOptions implements RippleGlobalOptions {

  /**
   * Whether ripples should be disabled. Ripples can be still launched manually by using
   * the `launch()` method. Therefore focus indicators will still show up.
   */
  disabled: boolean;
}

home.component.ts

import {Component} from '@angular/core';
import {AppRippleOptions} from './app-ripple-options';

@Component({
  ...
})
export class HomeComponent {

  constructor(private _rippleOptions: AppRippleOptions) {}

  toggleRippleDisabled() {
    this._rippleOptions.disabled = !this._rippleOptions.disabled;
  }
}

I'll be working on making this possible for the chips and tab-nav-bar as well. This is currently blocked by a deprecation until next major (7.0.0)

devversion added a commit to devversion/material2 that referenced this issue Jan 2, 2019
* Allows updating any global ripple option at runtime. This makes it possible for developers to disable ripples at runtime.

Closes angular#9729
devversion added a commit to devversion/material2 that referenced this issue Jan 2, 2019
* Allows updating any global ripple option at runtime. This makes it possible for developers to disable ripples at runtime.

Closes angular#9729
devversion added a commit to devversion/material2 that referenced this issue Jan 2, 2019
* Allows updating any global ripple option at runtime. This makes it possible for developers to disable ripples at runtime.

Closes angular#9729
devversion added a commit to devversion/material2 that referenced this issue Jan 9, 2019
* Allows updating any global ripple option at runtime. This makes it possible for developers to disable ripples at runtime.

Closes angular#9729
vivian-hu-zz pushed a commit that referenced this issue Jan 16, 2019
)

* feat(ripples): support updating global ripple options at runtime

* Allows updating any global ripple option at runtime. This makes it possible for developers to disable ripples at runtime.

Closes #9729

* fixup! feat(ripples): support updating global ripple options at runtime

Address feedback
s2-abdo pushed a commit to s2-abdo/material2 that referenced this issue Jan 18, 2019
…ular#14705)

* feat(ripples): support updating global ripple options at runtime

* Allows updating any global ripple option at runtime. This makes it possible for developers to disable ripples at runtime.

Closes angular#9729

* fixup! feat(ripples): support updating global ripple options at runtime

Address feedback
s2-abdo pushed a commit to s2-abdo/material2 that referenced this issue Jan 18, 2019
…ular#14705)

* feat(ripples): support updating global ripple options at runtime

* Allows updating any global ripple option at runtime. This makes it possible for developers to disable ripples at runtime.

Closes angular#9729

* fixup! feat(ripples): support updating global ripple options at runtime

Address feedback
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants