MCPcopy
hub / github.com/tdewolff/minify / createEmphasisDefaultState

Function createEmphasisDefaultState

_benchmarks/sample_echarts.js:12132–12180  ·  view source on GitHub ↗
(el, stateName, targetStates, state)

Source from the content-addressed store, hash-verified

12130 }
12131
12132 function createEmphasisDefaultState(el, stateName, targetStates, state) {
12133 var hasSelect = targetStates && indexOf(targetStates, 'select') >= 0;
12134 var cloned = false;
12135
12136 if (el instanceof Path) {
12137 var store = getSavedStates(el);
12138 var fromFill = hasSelect ? store.selectFill || store.normalFill : store.normalFill;
12139 var fromStroke = hasSelect ? store.selectStroke || store.normalStroke : store.normalStroke;
12140
12141 if (hasFillOrStroke(fromFill) || hasFillOrStroke(fromStroke)) {
12142 state = state || {}; // Apply default color lift
12143
12144 var emphasisStyle = state.style || {};
12145
12146 if (!hasFillOrStroke(emphasisStyle.fill) && hasFillOrStroke(fromFill)) {
12147 cloned = true; // Not modify the original value.
12148
12149 state = extend({}, state);
12150 emphasisStyle = extend({}, emphasisStyle); // Already being applied 'emphasis'. DON'T lift color multiple times.
12151
12152 emphasisStyle.fill = liftColor(fromFill);
12153 } // Not highlight stroke if fill has been highlighted.
12154 else if (!hasFillOrStroke(emphasisStyle.stroke) && hasFillOrStroke(fromStroke)) {
12155 if (!cloned) {
12156 state = extend({}, state);
12157 emphasisStyle = extend({}, emphasisStyle);
12158 }
12159
12160 emphasisStyle.stroke = liftColor(fromStroke);
12161 }
12162
12163 state.style = emphasisStyle;
12164 }
12165 }
12166
12167 if (state) {
12168 // TODO Share with textContent?
12169 if (state.z2 == null) {
12170 if (!cloned) {
12171 state = extend({}, state);
12172 }
12173
12174 var z2EmphasisLift = el.z2EmphasisLift;
12175 state.z2 = el.z2 + (z2EmphasisLift != null ? z2EmphasisLift : Z2_EMPHASIS_LIFT);
12176 }
12177 }
12178
12179 return state;
12180 }
12181
12182 function createSelectDefaultState(el, stateName, state) {
12183 // const hasSelect = indexOf(el.currentStates, stateName) >= 0;

Callers 1

elementStateProxyFunction · 0.85

Calls 4

hasFillOrStrokeFunction · 0.85
liftColorFunction · 0.85
indexOfFunction · 0.70
extendFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…