Skip to content

docs(ripple): update documentation #7941

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

Merged
merged 3 commits into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions src/lib/core/ripple/README.md

This file was deleted.

93 changes: 93 additions & 0 deletions src/lib/core/ripple/ripple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Connect user input to screen reactions by using ripples to both indicate the point of touch, and to
confirm that touch input was received. For touch or mouse, this occurs at the point of contact.

The `matRipple` attribute directive defines an area in which a ripple animates on user interaction.

```html
<div matRipple [matRippleColor]="myColor">
<ng-content></ng-content>
</div>
```

By default, a ripple is activated when the host element of the `matRipple` directive receives
mouse or touch events. Upon being pressed, a ripple will begin fading in from the point of contact,
radiating to cover the host element. Each ripple will fade out only upon release of the mouse or touch.

Ripples can also be triggered programmatically by getting a reference to the MatRipple directive
and calling its `launch` method.


### Ripple trigger

By default ripples will fade in on interaction with the directive's host element.
In some situations, developers may want to show ripples on interaction with *some other* element,
but still want to have the ripples placed in another location. This can be done by specifying
the `matRippleTrigger` option that expects a reference to an `HTMLElement`.

```html
<div>
<div matRipple [matRippleTrigger]="trigger" class="my-ripple-container">
<!-- This is the ripple container, but not the trigger element for ripples. -->
</div>

<div #trigger></div>
</div>
```

### Manual ripples

Ripples can be shown programmatically by getting a reference to the `MatRipple` directive.

```ts
class MyComponent {

/** Reference to the directive instance of the ripple. */
@ViewChild(MatRipple) ripple: MatRipple;

/** Shows a centered and persistent ripple. */
launchRipple() {
const rippleRef = this.ripple.launch(0, 0, {
persistent: true,
centered: true
});

// Fade out the ripple later.
rippleRef.fadeOut();
}
}
```

In the example above, the `x` and `y` parameters will be ignored, because the `centered`
ripple option has been set to `true`.

Ripples that are being dispatched programmatically can be launched with the `persistent` option.
This means that the ripples will not fade out automatically, and need to be faded out using
the `RippleRef` (*useful for focus indicators*).

### Global options

Developers are able to specify options for all ripples inside of their application.

The speed of the ripples can be adjusted and the ripples can be disabled globally as well.

Global ripple options can be specified by setting the `MAT_RIPPLE_GLOBAL_OPTIONS` provider.

```ts
const globalRippleConfig: RippleGlobalOptions = {
disabled: true,
baseSpeedFactor: 1.5 // Ripples will animate 50% faster than before.
}

@NgModule({
providers: [
{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useValue: globalRippleConfig}
]
})
```

All currently available global options are shown here:
Copy link
Member

Choose a reason for hiding this comment

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

Could this just be captured by API docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Interfaces are not being displayed in the docs yet. We might be able to change the interface to a class, but I'd rather would like to setup Dgeni to show interfaces (in a follow-up)


| Name | Type | Description |
| --------------- | ------- | ----------------------------------------- |
| disabled | boolean | Whether ripples should show or not. |
| baseSpeedFactor | number | Factor to adjust ripple speed. |