-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add example for dependent attribute values
- Loading branch information
1 parent
f7c6a14
commit 3cd4547
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,20 @@ | ||
// title: dynamic attributes depending on each other | ||
|
||
import {Marker} from './lib/marker'; | ||
|
||
// dynamic attributes can be written to reliably depend on the current value | ||
// of another attribute, for example to make colors depend on the icon shown | ||
// or make colors depend on each other. Note that this also works when | ||
// depending on other dynamic attributes. | ||
// | ||
// Returning undefined for the borderColor causes the borderColor to be set | ||
// automatically via the color attribute. | ||
|
||
export default (map: google.maps.Map) => { | ||
const marker = new Marker({ | ||
position: {lat: 53.55, lng: 10.05}, | ||
color: ({marker}) => (marker.hovered ? 'red' : 'green'), | ||
borderColor: ({attr}) => (attr.color === 'red' ? 'black' : undefined), | ||
map | ||
}); | ||
}; |