Skip to content

Commit e4299f8

Browse files
examples(project-data): update SDK usage example for update project data
partial advanced.
1 parent 331a22d commit e4299f8

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

examples/project-data/update-project-data-partial-advanced.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,41 @@ async function sample () {
5252
voiceOver: false
5353
}
5454

55-
const sounds = [ sound1, sound2 ]
55+
const sounds = [sound1, sound2]
5656
projectDataInstance.setSounds(sounds)
5757

5858
const screens = projectDataInstance.getScreens()
5959
// set text on text holder area
6060
if (screens && screens[0]) {
61+
// check if screen duration is adjustable do some manipulations
62+
const isAdjustable = screens[0].isDurationAdjustable()
63+
64+
if (isAdjustable) {
65+
const calculateDuration = screens[0].calculateScreenDuration()
66+
console.log(calculateDuration)
67+
const maxDuration = screens[0].getMaxPossibleDuration()
68+
const desiredDuration = 5
69+
70+
if (desiredDuration <= maxDuration) {
71+
screens[0].setDuration(desiredDuration)
72+
}
73+
}
74+
// check if icon position is adjustable, then change the icon position
75+
if (screens[0].isIconPositionAdjustable()) {
76+
screens[0].changeIconPosition()
77+
}
78+
6179
const areas = screens[0].getAreas()
6280

6381
const area = areas[0]
6482
if (area && area.type === 'text') {
65-
area.setText('sample text')
83+
// check recommended character count for current area
84+
const recommendedCharacterCount = area.getRecommendedCharacterCount()
85+
const sampleText = 'sample text'
86+
87+
if (sampleText.length <= recommendedCharacterCount) {
88+
area.setText(sampleText)
89+
}
6690
}
6791
}
6892
// set image on image holder area
@@ -145,7 +169,7 @@ async function sample () {
145169
areas: [
146170
{
147171
id: 3562168,
148-
cords: [ 656, 224, 1048, 224, 1048, 332, 656, 332 ],
172+
cords: [656, 224, 1048, 224, 1048, 332, 656, 332],
149173
height: 108,
150174
order: 0,
151175
title: 'char_Angry_2',

0 commit comments

Comments
 (0)