I would like to shake some webcontrol when a password is wrong for example
I tried :
mLogonPanel.ExecuteJavaScript( "$(""#"+mLogonPanel.ControlID+""").effect(""shake"");")
but nothing happens, and no error on the browser debug panel.
any hint ?
thanks.
I would do it with css keyframe animations.
Just add the css class to the container and the css does the job for you.
For example with something like:
The ultimate web code generators. Generate HTML, CSS, JSON-LD, Twitter Cards, Open Graph and more! No coding skills required.
DerkJ
(DerkJ)
December 8, 2021, 9:34pm
3
Try:
mLogonPanel.ExecuteJavaScript( "$("'#"+mLogonPanel.ControlID+"'").effect(""shake"");")
it could be you need something after mLogonPanel.ControlID+"_something"
check your browser context menu on the field or control â inspect.
https://www.tutorialspoint.com/jquery/effect-shake.htm
jquery is already in your web app.
still doesnât work
this is the container Iâm using. there is no â_somethingâ after the controlID
I was able to get it to work â let me try and post a module with the code.
1 Like
thank you very much for this.
sorry but it does not seems to work on my macos high sierra and opera or safari.
ps: I find it extreme that you need a websdkcontrol to make this âsimpleâ thing work !
The big thing is including the right bit of JavaScript. There is probably another way but you can see it is only a bit of Xojo code.
css should be easier than a websdkcontrol ⊠but Iâm complete noob with css !
but howto convert this css code to a xojo webstyle ? is it a transition ?
Just a question: I see you are using JQuery. Have you embedded the jquery library into your app ?
if you look at the source html of a xojo web page, jquery is already embedded.
as Derk said some posts above.
1 Like
DerkJ
(DerkJ)
December 9, 2021, 6:48pm
13
Itâs there by default in a webapp.
1 Like
DerkJ
(DerkJ)
December 9, 2021, 6:54pm
14
Ah sorry i see there is no such effect in âjqueryâ itâs in jquery-ui.
But there is these:
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
You can âanimateâ for example:
mLogonPanel.ExecuteJavaScript( "$("'#"+mLogonPanel.ControlID+"'").animate('{width: ""+=50px""}');")
queueing:
2 Likes
or include jquery-ui in the app html header ?
DerkJ
(DerkJ)
December 9, 2021, 8:25pm
16
can do, but just for effects⊠?
well, this still doesnât shake or animate any pixel of my webcontainer !
Dim js As String
For i As Integer = 1 To 10
js = js + "$('#"+mLogonPanel.ControlID+"').animate('{left:'"+Str(mLogonPanel.Left-5)+"'},50);"
js = js + "$('#"+mLogonPanel.ControlID+"').animate('{left:'"+Str(mLogonPanel.Left+5)+"'},50);"
Next i
mLogonPanel.ExecuteJavaScript( js.ToUTF8)
Do you have the macOS Accessibility setting âReduce Motionâ enabled? This can prevent browsers from animating some effects.
1 Like
good catch, but nope this accessibility checkbox is unchecked on my system.
2 Likes
I once tried to use CSS to size automatically controls (early work on RubberViewsWE). Problem is, the size of controls is tightly controlled, it did not work.
You may be in the same case.
But it should be possible to use a timer to move the control back and forth in pure Xojo.
AlbertoD
(AlbertoD)
December 9, 2021, 11:28pm
21
One option is to add the shake CSS to the HTML Header:
<style>@keyframes shake {
0% { transform: translate(1px, 1px) rotate(0deg); }
10% { transform: translate(-1px, -2px) rotate(-1deg); }
20% { transform: translate(-3px, 0px) rotate(1deg); }
30% { transform: translate(3px, 2px) rotate(0deg); }
40% { transform: translate(1px, -1px) rotate(1deg); }
50% { transform: translate(-1px, 2px) rotate(-1deg); }
60% { transform: translate(-3px, 1px) rotate(0deg); }
70% { transform: translate(3px, 1px) rotate(-1deg); }
80% { transform: translate(-1px, -1px) rotate(1deg); }
90% { transform: translate(1px, 2px) rotate(0deg); }
100% { transform: translate(1px, -2px) rotate(-1deg); } }
</style>
Used the code from: How To Shake an Image
Then set the style for the control that you want to shake, this is for a WebRectangle with a button and a label:
Rectangle1.Style.Value("animation") = "shake 0.5s"
You will need to reset the style to be able to shake again:
Rectangle1.Style.Value("animation") = ""
We can do something like this:
5 Likes