-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Expand EE flow from AdUnitBox or DateTimeBranch (#903)
* Refactor timeline code. * Add flow expander component and modify branches according to it. * Remove unnecessary arguments. * Add cursor marker. * Add auto expand checkbox. * Move amp-player-main to custom scripts * Remove displaying arrow in auto expand mode. * Integrate autoExpand workflow with extension. * Move flow expander to components from modules. * Rotate the icon which was selected. * Fix bugs.
- Loading branch information
Showing
16 changed files
with
393 additions
and
245 deletions.
There are no files selected for viewing
File renamed without changes.
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
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
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
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
78 changes: 78 additions & 0 deletions
78
packages/explorable-explanations/src/protectedAudience/components/flowExpander.js
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,78 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import app from '../app'; | ||
import config from '../config'; | ||
import { isInsideCircle } from '../utils'; | ||
|
||
const FlowExpander = async ({ nextTipCoordinates }) => { | ||
const p = app.p; | ||
const igp = app.igp; | ||
const iconSize = config.timeline.expandIconSize; | ||
const iconRadius = iconSize / 2; | ||
|
||
igp.mouseMoved = ({ offsetX, offsetY }) => { | ||
let hoveringOverSomething = false; | ||
nextTipCoordinates.forEach(({ x, y }) => { | ||
if (isInsideCircle(offsetX, offsetY, x, y + 27, iconRadius)) { | ||
hoveringOverSomething = true; | ||
} | ||
}); | ||
if (hoveringOverSomething) { | ||
p.cursor('pointer'); | ||
} else { | ||
p.cursor('default'); | ||
} | ||
}; | ||
|
||
const endpoint = await new Promise((resolve) => { | ||
igp.mouseClicked = ({ offsetX, offsetY }) => { | ||
nextTipCoordinates.forEach(({ x, y }) => { | ||
if (isInsideCircle(offsetX, offsetY, x, y + 27, iconRadius)) { | ||
igp.mouseClicked(false); | ||
igp.mouseMoved(false); | ||
resolve({ x, y }); | ||
return; | ||
} | ||
}); | ||
}; | ||
}); | ||
|
||
nextTipCoordinates.forEach(({ x, y }) => { | ||
p.push(); | ||
p.noStroke(); | ||
p.circle(x, y + 27, 25); | ||
p.pop(); | ||
|
||
if (endpoint.x !== x) { | ||
p.push(); | ||
p.tint(255, 90); | ||
p.image(p.expandIcon, x - iconRadius, y + 17, iconSize, iconSize); | ||
p.pop(); | ||
} else { | ||
p.push(); | ||
p.rotate(p.TWO_PI / 2, [1, 1, 0]); | ||
p.image(p.expandIcon, -x - iconRadius, -y - 35, iconSize, iconSize); | ||
p.pop(); | ||
} | ||
}); | ||
|
||
return endpoint; | ||
}; | ||
|
||
export default FlowExpander; |
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
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ const config = { | |
width: 30, | ||
height: 30, | ||
}, | ||
expandIconSize: 20, | ||
circles: [ | ||
{ | ||
type: 'advertiser', | ||
|
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
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
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
Oops, something went wrong.