Help with Ng and ui Template Carousel

I am using the ui Template for a picture carousel, with ng-swipes incrementing or decrementing the index value which I can send out of the Template as a payload. However, I cannot find a way to read input msg values into UI for use in ng-swipes so that I can reset the carousel at its limits. Any help appreciated.

<img src = "data:image/png;base64,{{msg.payload}}" 
ng-swipe-right = "i = i + 1;send({payload:i})" 
ng-swipe-left = "i = i - 1;send({payload:i})"
ng-hide = "showToggle"
ng-click = "send({payload:msg.vid});showToggle=!showToggle" 
/>

The display limit is set outside the UI Template and and controls the start and end pictures, but swiping beyond the limit on those pictures requires the same number of swipes back in order to resume the Carousel.

Maybe this will help

[{"id":"1c40ee1352c943b0","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":4600,"wires":[]},{"id":"75d423fa.e0c8fc","type":"ui_template","z":"bf9e1e33.030598","group":"1c2e0ff9fd3d33d8","name":"","order":14,"width":0,"height":0,"format":"<img src = \"{{msg.payload}}\" \nng-swipe-right = \"send({index:msg.index+1})\" \nng-swipe-left = \"send({index:msg.index-1})\"\nng-hide = \"msg.hide\"\n ng-Dblclick = \"send({index:msg.index, payload: msg.vid})\" \n/>\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"","x":490,"y":4660,"wires":[["1c40ee1352c943b0","15e2b9f0.e3f886"]]},{"id":"aced6318.939fb8","type":"ui_button","z":"bf9e1e33.030598","name":"","group":"1c2e0ff9fd3d33d8","order":11,"width":"6","height":"1","passthru":false,"label":"reset","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"0","payloadType":"num","topic":"topic","topicType":"msg","x":100,"y":4680,"wires":[["d2c2db7a.bbbc"]]},{"id":"43ef438a.17d77c","type":"ui_numeric","z":"bf9e1e33.030598","name":"","label":"","tooltip":"","group":"1c2e0ff9fd3d33d8","order":11,"width":"3","height":"1","wrap":true,"passthru":false,"topic":"topic","topicType":"msg","format":"{{value}}","min":0,"max":"2","step":1,"className":"","x":90,"y":4720,"wires":[["d2c2db7a.bbbc"]]},{"id":"d2c2db7a.bbbc","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"index","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":4720,"wires":[["15e2b9f0.e3f886"]]},{"id":"15e2b9f0.e3f886","type":"change","z":"bf9e1e33.030598","name":"index","rules":[{"t":"set","p":"hide","pt":"msg","to":"$exists($$.payload)","tot":"jsonata"},{"t":"set","p":"index","pt":"msg","to":"$$.index  > 2 ? 0 : ($$.index < 0 ? 2 : $$.index)","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"[\t\"https://sipi.usc.edu/database/preview/misc/4.1.08.png\",\t\"https://sipi.usc.edu/database/preview/misc/4.2.03.png\",\t\"https://sipi.usc.edu/database/preview/misc/4.2.05.png\"\t][$$.index]","tot":"jsonata"},{"t":"set","p":"vid","pt":"msg","to":"[\"one\",\"two\",\"three\"][$$.index]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":4720,"wires":[["75d423fa.e0c8fc","96023956.1e426"]]},{"id":"96023956.1e426","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"index","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":4800,"wires":[["43ef438a.17d77c"]]},{"id":"1c2e0ff9fd3d33d8","type":"ui_group","name":"Stand","tab":"8c85a1ca378342da","order":1,"disp":true,"width":"10","collapse":false,"className":""},{"id":"8c85a1ca378342da","type":"ui_tab","name":"Read Standard test","icon":"dashboard","order":16,"disabled":false,"hidden":false}]

I changed ng-click to double click, as the drag was causing issues on my test device.

1 Like

Thanks, I should have realised that I could alter the msg.index, but because the the ui Template doesn't pass on the input messages I became transfixed with reading the index into ng, rather than altering it the Template and resending. Bit of a senior moment.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.