Skip to content

Cudi7/JavaScript_Elevator-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elevator app build with JavaScript

Live demo

https://nostalgic-benz-337914.netlify.app

Design preview for the  coding challenge

Table of contents

General info

Project idea from freecodecamp: More project ideas to improve your coding skills

https://www.freecodecamp.org/news/more-project-ideas-to-improve-your-coding-skills-99f48d09bb4b/

Code Examples

./js/script.js

import Elevator from './Elevator.js';

//select all btns
const AllbuttonFloor = document.querySelectorAll('.btn-floor');
const ELEVATOR_TOTAL_DISTANCE = 392; // total distance from bottom to top
const ELEVATOR_FLOOR_DISTANCE = 65.33; // total distance each floor

// generates instace of a class Elevator
const elevator = new Elevator(ELEVATOR_TOTAL_DISTANCE, ELEVATOR_FLOOR_DISTANCE);

//return current elevator position and elevator element
const elevatorPosition = () => {
  const elevator = document.querySelector('.elevator');

  const style = getComputedStyle(elevator);
  return [style.bottom.split('px')[0], elevator];
};

//handle click event
function handleClick(e) {
  elevator.buttonPressed(e.target);
}

//listen to click event on  each btn
AllbuttonFloor.forEach((btn) => btn.addEventListener('click', handleClick));

export { elevatorPosition, elevator };

Features

You can:

  • Do the usual stuff that you could do on an elevator

Technology used

The project is created with:

  • JavaScript

Contact

Coded by Cudi - feel free to contact me!

About

Elevator App build using only JavaScript OOP

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published