-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
mmalerba
merged 3 commits into
angular:master
from
devversion:docs/ripple-documentation
Oct 27, 2017
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
||
| Name | Type | Description | | ||
| --------------- | ------- | ----------------------------------------- | | ||
| disabled | boolean | Whether ripples should show or not. | | ||
| baseSpeedFactor | number | Factor to adjust ripple speed. | |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)