How to override Viewers api.stop() function?


(Vip Saran) #1

I wanted to provide different functionality when user presses the viewer close button, but overriding it as:

api.stop = function(callback) {
  console.log('overriden stop');

does nothing. Ideas?

(Shaderbytes) #2

you cant override the stop button code in the viewer, but you can hide the default stop button. You can then add a stop button of your own to the viewer and add whatever code logic required.

(Vip Saran) #3

Oh, well...

How? :slight_smile:

(Shaderbytes) #4

using the "ui_stop" initialization option :

(Vip Saran) #5

Sorry, I'm a bit thick. Can't find a way to add my own button once I remove the default one.

(Shaderbytes) #6

That is beyond the scope of help in this forum. You need to have web development experience to do this. I presumed you did since you were pasting javascript code snippets here. Also you can only do these things on external embeds , meaning not on models displayed on the sketchfab domain.