MCPcopy Create free account
hub / github.com/microsoft/SandDance / newTextLayer

Function newTextLayer

docs/tests/v2/es6/js/sanddance.js:146201–146244  ·  view source on GitHub ↗
(presenter, id, data, config, fontFamily)

Source from the content-addressed store, hash-verified

146199}
146200
146201function newTextLayer(presenter, id, data, config, fontFamily) {
146202 const props = {
146203 id,
146204 data,
146205 coordinateSystem: _base.base.deck.COORDINATE_SYSTEM.IDENTITY,
146206 autoHighlight: true,
146207 pickable: true,
146208 getHighlightColor: config.getTextHighlightColor || (o => o.color),
146209 onClick: (o, e) => {
146210 let pe = e && e.srcEvent; //handle iOS event
146211
146212 if (e.center) {
146213 pe = {
146214 clientX: e.center.x,
146215 clientY: e.center.y
146216 };
146217 }
146218
146219 config.onTextClick && config.onTextClick(pe, o.object);
146220 },
146221 onHover: (o, e) => {
146222 if (o.index === -1) {
146223 presenter.deckgl.interactiveState.onText = false;
146224 } else {
146225 presenter.deckgl.interactiveState.onText = config.onTextHover ? config.onTextHover(e && e.srcEvent, o.object) : true;
146226 }
146227 },
146228 getColor: config.getTextColor || (o => o.color),
146229 getTextAnchor: o => o.textAnchor,
146230 getSize: o => o.size,
146231 getAngle: o => o.angle,
146232 fontSettings: {
146233 sdf: true,
146234 fontSize: 128,
146235 buffer: 3
146236 }
146237 };
146238
146239 if (fontFamily) {
146240 props.fontFamily = fontFamily;
146241 }
146242
146243 return new _chromaticTextLayer.ChromaticTextLayer(props);
146244}
146245
146246function getTiming(duration, easing) {
146247 let timing;

Callers 1

getLayersFunction · 0.70

Calls 1

onTextHoverMethod · 0.45

Tested by

no test coverage detected