I have this in my html (SVG is about 500K):

我在GitHub上使用脚本为SVG创建一个视口,这样我就可以在视口内平移和缩放,但是像GoogleMaps一样.

https://github.com/ariutta/svg-pan-zoom

所以加载顺序需要是:

> svg-pan-zoom.js完成>所有500k的svg需要完成加载>需要运行以下代码:

var panZoomArm = svgPanZoom(‘#arm’);

不幸的是,上面的代码在SVG没有完全加载时运行,导致错误.

我试过这个但是.load似乎不是为< object>而设计的. – 实际上调试器永远不会被触发

$('#arm').load(function(){ debugger var panZoomArm = svgPanZoom('#arm');});

这些方法对我来说只有在500k svg完全下载后才能告诉代码运行吗?

让我可靠地启动此代码的唯一方法是使SVG完全内联…这样就像数百行代码无法缓存.

编辑 – –

好吧,我让它工作,但我很困惑.

这不起作用(调试器永远不会触发):

$('#arm').load(function(){ debugger var panZoomArm = svgPanZoom('#arm');});

这有效:

var arm = document.getElementById("arm");arm.addEventListener('load', function(){ debugger var panZoomArm = svgPanZoom('#arm');});

解决方法:

这就是我开始工作的方式:

var arm = document.getElementById("arm");arm.addEventListener('load', function(){ var panZoomArm = svgPanZoom('#arm');});

javascript - how to wait for SVG inside to finish loading before some JS fires? Related posts

  1. How can I test my application on my phone? I have Eclipse w/ Android plugin

    Where do I copy the apk file on Motorola Droid? Which directory? I need to be careful if there is any possible problem, it is also my personal phone...Best answer:To install the apk file, you need to executeadb install /path/to/file.apkAlthough the robot is connected. I will avoid using other adb pr ...

  2. IronPython w/ C# - How to read the value of a Python variable

    I have two python files: mainfile.py and subfile.pymainfile.py depends on some types in subfile.py.mainfile.py looks like this.from subfile import *my_variable = [1,2,3,4,5]def do_something_with_subfile #Do something with things in the subfile. #Return something.I'm trying to load mainfile.py in C# ...

  3. How to Build a Shopping List Using React Hooks (w/ Starter Code and Video Walkthrough)

    What we're buildingIn this beginner React tutorial, we're going to build a shopping app. We'll work with complex state objects, update parts of the state, and use existing state to calculate new state.Check it out here:Try it yourselfIf you want to have a go yourself first, here are the scenarios (y ...

  4. Python regular expressions \W* and \W*? Problems encountered in the matching process

    When Lao Yuan analyzed the problem in"In-depth analysis of the matching process of Python regular expressions \W+ and \W*", he thought of a question, if"re.split('(\W*)','Hello, world') What will happen if the processing of"is changed to non-greedy mode? According to the prediction of the old monkey ...

  5. Use PHP and ImageMagick to programmatically convert RGB images to 1-bit grayscale (b/w) bitmap images

    I am trying to use PHP (version: 5.2.13) and ImageMagick (version: 6.7.8-7-Q16) to programmatically convert a bitmap RGB image to a 1-bit grayscale (b/w) bitmap image. Input image It is a bitmap, generated by the ImageMagick function:bool Imagick::setFormat ( string $format )Where $format ='bmp2'The following code has been used in the past (old version of ImageMagick...don’t remember which one), but it doesn’t work anymore in the current environment:private function monochrome() { if (isset($thi ...

  6. In-depth analysis of the matching process of Python regular expressions \W+ and \W*

    In the process of learning the re.split function, it was found that the execution and return of the following statements were inconsistent with what the old ape had expected:&gt;&gt;&gt; re.split('\W*','Hello, world')['','H','e','l','l','o','','w', 'o','r','l','d','']What the old ape expects is ['', ...

  7. javascript-How to make ExtJS include the time zone when saving records from JSONStore w/ ISO 8601 format?

    In the code snippet below, I created a JsonStore (its record type is a single date field), added a new record to it, and then saved it. When saving, the time zone is not included in the serialized date value, even if it is included in the actual In the record object (as shown by Firebug). Ext seems ...

  8. php-Laravel 4.1 Wherein w/Many-to-many relationship and conditions?

    I'm developing an application, part of the application needs to use AND to search multiple different fields on the same model-age can also be found, where the AND gender between $from and $to is $gender. The place where I get lost is The model has many relationships with Category, so I need to filte ...

  9. javascript - ECMAScript associative array via object w/ prototype null?

    I see a lot of people doing thisObject.prototype.foo = 'HALLO';var hash = {baz: 'quuz'};for ( var v in hash ) { // Do not print property `foo` if ( hash.hasOwnProperty(v) ) { console. log( v +"is a hash property"); }}My question is, instead of testing .hasOwnProperty every time you want to use Objec ...

  10. python-Use the string subs('x','w') instead of the symbol subs(x,w) to replace Sympy

    I am working on an application with a circuit simulator ahkab, to make a long story short I need to replace the laplace variable s in some equations with 1j*w. For me, the symbol name is used instead of the symbol itself to perform this substitution and other substitutions. Convenience. I encountered some strange behavior.If you do&gt;&gt;&gt; x = Symbol('x') &gt;&gt;&gt; y = Symbol('y') &gt;&gt;&gt; expr = x + y x + y &gt;&gt;&gt; expr.subs('x','w') w + yThis seems to work as I expected. The pr ...

  11. JavaScript: format number/currency w/ about culture, such as String.Format() in .NET?

    This seems to be a problem that someone has solved in 2009, but I can't find a decent JavaScript library with numbers like this:12,345.58And format it correctly according to the specific culture (ie"nl-nl") or ISO currency code.dojo shows promise, but it doesn't contain many cultures by default, and ...

  12. java - How does a JVM running multiple threads handle ctrl-c, w/ and w/o shutdown hooks?

    Couldn't find this answer online. When pressing Ctrl C:What happens to the running threads when we don't have any shutdown hooks - they are each hit with InterruptedException? When we have shutdown hooks, I know that shutdown hooks run in new threads in arbitrary order. But what happens to existing ...

  13. How to create a hash code in C# on the object graph provided by W# service

    I currently have a WCF service that can provide an object graph of data on request. I want to have a mechanism where the client can calculate a hash on the cached object graph it owns, and then can provide the hash value to WCF service to see if it matches the data owned by the service.I tried this ...

  14. is marked as 1.5w on GitHub, used by station B, and the monthly salary of flv.js open source authors is less than 5k! How important is education to programmers?

    big data abstracts author: Liu Junhuan introduced to you the annual salary level of data scientists in the United States last week, and found that although the overall salary trend of scientists has declined, the median annual salary remains at about 120,000 US dollars. At the same time, Zhihu's las ...

  15. [timeisprecious][JavaScript ]JavaScript RegExp \W Metacharacter

    JavaScript&gt;RegExp regular expression&gt; \W metacharacter1. From RunnobJavaScript RegExp \W metacharacterDefinition and usage:The \W metacharacter is used to find non-word characters.Word characters include: az, AZ, 0-9, and underscore.grammar:new RegExp("\W") or a simpler way: /\W/Demo:Case Code ...

  16. C#Web request w RestSharp-"Request aborted: unable to create SSL/TLS secure channel"

    I have a very simple web request with RestSharp:var client = new RestClient("https://website.net"); var request = new RestRequest("/process", Method.GET); request.AddParameter("cmd", "execute"); IRestResponse response = client.Execute(request); var content = response.Content; Console.WriteLine("Response: "+ content);This will return the error message:The request was aborted: Could not create SSL/TLS secure channelthree things:&gt; I got the response I expected through the browser, &gt; I got th ...

Recent Posts

  1. C# IE option settings (2)

    IE settings can be modified through the registry. The following are some commonly used IE settings registry modifications~Check for certificate revocation 1 ///2 /// Check whether the certificate is revoked 3 ///4 ///5 public void SetCertificateVerificationState(bool isOpen) 6 {7 //Check whether the...

  2. java-FontMetrics is incorrect when running on an Android device. The emulator is fine

    I have an Android application that dynamically scales text based on the resolution of the Android device. I have tested this code on all predefined resolutions in the Android emulator, and my code is working fine. (This includes compatibility with HTC Desire and Motorola Droid same resolution)It als...

  3. The sub-pages in PHP-Pico installation cause 404

    I downloaded a lightweight PHP CMS solution called Pico and put the files in the MAMP installation. When I visit the default homepage, everything seems to work fine, but when I click to point to the"subpage"( http://localhost:8888/pico/subdir/), I entered the general 404 page. Since the subpage is l...

  4. java-some help about hibernate Criteria query

    Can someone help me complete/clean up this query. I am trying to get the number of rows in the table first, and then I need to actually get a set of rows. I am not sure how to use the same condition instance to execute two queries.To get the count I have something like this:Criteria criteria = sessi...

  5. Using Java to upload https files?

    How to upload files via https (secure) using Java? When I send the same message as http url, it will throw an exception like"javax.net.ssl.SSLHandshakeException: The remote host closed the connection during handshake". Can anyone guide me, how to upload files in https using Java? Thanks in advance.....

  6. java – Spring JMS Activemq – Set Dead Letter Queue Name (DLQ)

    We have 3 different projects running on the same ACTIVEMQ agent. Currently there is a"DLQ"queue, and we want to set up dlq for each web application as follows:dlq_webapp1dlq_webapp2dlq_webapp3This way we can better control the retry process. How do we configure it like this? Here are some of our mes...

  7. javascript-how to bind a string to the range var in the view?

    I want to bind a string to a scope var, which will get its value through the user's input in an input field inside the view. Therefore, the string connected to the range var value should be displayed in another div of the view .It should look like this:Name:{{"Hello"+ userInput}}But the problem here...

  8. javascript-jQuery to find the height of the image, even if

    I have a weird problem. I am running a simple query that finds the largest image on the page. Here is some test data-all pictures are 32×32, but one of the pictures is 300×300 in size .If I run a simple query like this:$('img').each(function(){ console.log($(this).height()); });I will get 0,0,300 - ...

  9. java-using Jersey's dynamic instance-level authorization (based on id)

    Sorry, I’m still new to Jersey. I’ve been trying to find a way to use Jersey resources for instance-level access authorization, but the most granular I have seen are role or static instance-level permissions. I’m a bit confused, becauseIn order to better describe what I mean: suppose a user has a se...

  10. RVM solves Ruby version problems

    RVM is a command line tool that can provide a convenient multi-version Ruby environment management and switching.The official website of RVM is https://rvm.io/. If you plan to learn Ruby / Rails, RVM is one of the essential tools.All the commands here are operated under user authority. It is best no...