current position:Home>Class object oriented programming idea
Class object oriented programming idea
2022-06-24 09:51:25【Time202051】
<main>
<div id="app" style="width: 200px; height: 200px; background:#E34334">houdunren.com</div>
</main>
<script>
class Ad {
constructor(options) {
this.$el = document.querySelector(options.el)
this.$options = Object.assign({
timeout: 2, step: 1 }, options)
// Initial movement direction ,1 Down / towards the right -1 Up / towards the left
this.x = this.y = 1
// Set positioning mode
this.$el.style.position = 'fixed'
setInterval(this.run.bind(this), this.$options.timeout)
}
// Timing callback function
run() {
this.$el.style.left = this.left() + 'px'
this.$el.style.top = this.top() + 'px'
}
left() {
let {
x, width } = this.$el.getBoundingClientRect()
let {
clientWidth } = document.documentElement
if (x > clientWidth - width) this.x = -1
if (x < 0) this.x = 1
return x + this.x * this.$options.step
}
top() {
let {
y, height } = this.$el.getBoundingClientRect()
let {
clientHeight } = document.documentElement
if (y > clientHeight - height) this.y = -1
if (y < 0) this.y = 1
return y + this.y * this.$options.step
}
}
new Ad({
el: '#app', timeout: 10, step: 1 })
</script>
copyright notice
author[Time202051],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/175/202206240903258858.html
The sidebar is recommended
- The birth of atomic quantum circuit marks a major breakthrough in quantum computer technology
- How to locate lock waiting in Dameng database
- Easily play with IOS 16 lock screen interface
- How to open an account online for new bonds? Please bless me
- React usestate storage function
- What else can the project implementation engineer do without the project?
- Precautions when applying to upgrade springcloud Version (Dalston to Edgware)
- A docker implemented by shell script
- Android studio simulator modify system language / enable Developer mode / customize resolution and size
- Android uses itemtouchhelper to realize item dragging position exchange and side sliding deletion of recyclerview
guess what you like
Why does the menu bar created with QT in vs report errors
Oauth2 released methods cannot be accessed
About pyopengl: why is the obj model (dinosaur) read and displayed like this? How can it display the same material effect as the teapot
CSS problem, card jitter
Jpprofiler monitors the problem of excessive memory deployed under Tomcat
A HashMap talked with the interviewer for half an hour
Java interview experience in a small company
I have made an application to visually generate echarts code, so I don't have to look at complex documents anymore (attached with project source code)
Can you do it as soon as possible? There is not much time
For non front and rear end separation projects, how can the front and rear ends be separated and packaged separately?
Random recommended
- () is a linear table that restricts the internal structure of data elements to only one character. A. Stack B. queue C. string D. array
- TS cannot find global variable for NPM package
- Java, what should I do if there is an edit configuration in the idea when it runs
- C++ code. Freshmen have just come into contact with this language
- Tnsnames Ora file configuration
- Handling method of Oracle data file header SCN inconsistency
- Oracle database listening file configuration
- Oracle database expdp only exports tables
- Windows method for checking network port occupation and kill process
- Oracle viewing data file header SCN information
- Ora-28000 error after upgrading Oracle 12C to 19C
- [talk about serviceregistryendpoint of springcloud]
- [springcloud service registration and anti registration AOP interception]
- [springboot source code analysis - @endpoint annotation validation principle analysis]
- [elegant offline and grayscale release of spring cloud]
- PostgreSQL
- Reactnative 0.69 release
- The new design can be called a new generation. The gradient borderless grille has a high appearance value. The application drawing of Changan Ruicheng plus
- Linux general command summary
- Render external link address URL video page via iframe - Vue
- Detailed explanation of Linux system tuning (VII) -- network status viewing command nethogs
- Vue failed to parse source for import analysis because the content contains invalid JS syntax
- Differences between front-end set and map
- Difference between front-end foreach and map
- Front end array flattening
- How the front end judges the data type
- Front end CSS style expand and collapse
- Front end array de duplication
- Front end throttling and anti shake
- Analysis of 43 cases of MATLAB neural network: Chapter 33 prediction algorithm of fuzzy neural network -- water quality evaluation of Jialing River
- Java & c++ problem solving and expansion -- leetcode30 Concatenate substrings of all words [new knowledge of Mo]
- Eclipse customizes and calls the header file [c/c++]
- Detailed explanation of Vue Foundation
- Unity determines whether all toggles are selected or not
- Program reverse output and print results
- Ubuntu modify time zone
- Linux Installation maven
- Okhttp source code analysis of Android network framework
- Android adds system service interfaces and test cases
- Ubuntu deployment according to Vue version