- Element separation for improved DOM manipulation. ๐งฉ
- Utilizing
box-sizing
to include padding, margin, and border in height and width calculations. ๐ - Using
overflow: hidden
to prevent scrolling andoverflow
to clip container content. ๐ซ - Responsive design with
em
,rem
,vh
,vw
units. ๐ฑ flex-wrap
for responsive layout,flex-column
for vertical alignment. ๐- Media queries for max-width responsiveness. ๐ฅ๏ธ
- Animations for dynamic content transitions. ๐
- Additional Details:
box-sizing: border-box;
ensures that padding and border are included in the element's total width and height. ๐ฆoverflow: hidden;
disables scrolling, and strategic use ofoverflow
is employed to clip content. ๐- Units like
em
,rem
,vh
, andvw
are used for automatic responsiveness with width adjustments. ๐ flex-wrap
is applied for elements to stack vertically instead of overlapping. ๐- Animations are used for smooth transitions, like animating the displayed time. ๐
- Media queries with
max-width
are used for responsiveness, setting maximum widths for layout adjustments. ๐
- QuerySelector for accessing HTML elements using class and ID. ๐
- EventListener for constructing events, passing functions without parentheses. ๐ค
- Functions:
- Toggle Start:
- Determines whether to start or stop the stopwatch based on the current state (
isRunning
). โฏ๏ธ - Calls the appropriate function accordingly. ๐
- Determines whether to start or stop the stopwatch based on the current state (
- Start Stopwatch:
- Sets the
starttime
value. โฑ๏ธ - Adjusts the start time if the stopwatch was paused (
pausetime
is not zero). โธ๏ธ - Calls the
updateStopWatchFunction
to display and animate the stopwatch. ๐
- Sets the
- Pause Stopwatch:
- Sets
isRunning
to false. โธ๏ธ - Records the pause time (
pausetime
) as the current time minus the start time. โฑ๏ธ
- Sets
- Update Stopwatch:
- Calculates the elapsed time by subtracting the start time from the current time. โณ
- Calls the
formatTime
function to convert the elapsed time into hours, minutes, and seconds. ๐ฐ๏ธ - Calls the
displayTime
function to update the displayed time. ๐ - Initiates an animation for the displayed time. ๐
- Format Time:
- Performs mathematical calculations to obtain hours, minutes, and seconds from the given time. ๐งฎ
- Ensures the formatted time values are limited to two digits. ๐ข
- Returns an object containing the formatted time values. ๐
- Display Time:
- Updates the HTML content for hours, minutes, and seconds with the values received in the object parameter. ๐
- Resume Watch:
- Sets
isRunning
to true.โถ๏ธ - Adjusts
starttime
based on the original start time and any pause time. ๐ - Resets
pausetime
to zero. ๐ - Calls the
updateStopWatchFunction
to display and animate the resumed stopwatch. ๐
- Sets
- Reset Stopwatch:
- Resets the stopwatch to its initial state. ๐
- Sets
isRunning
to false,pausetime
to zero. โ - Calls
clearLaps
to clear lap records. ๐ - Resets lap number to 1. 1๏ธโฃ
- Updates the displayed time to zero. โฐ
- Clear Laps:
- Clears lap records by setting the
innerHTML
of the lap container to an empty string. ๐งน - Resets the lap number to 1. 1๏ธโฃ
- Clears lap records by setting the
- Record Laps:
- Checks if the stopwatch is running before creating a lap record. ๐
- Calculates lap time using the
formatTime
function. โฑ๏ธ - Creates a new div element using
createElement
. ๐ - Applies CSS styling to the div using
classList
. ๐จ - Updates the
innerHTML
of the div with lap details using template literals. ๐ - Appends the div to the lap container using
appendChild
. โ
- Toggle Start:
- Dynamic use of backticks and
${}
for string interpolation. ๐ - Consistent use of camelCase for function and variable names. ๐ซ
- Careful handling of conditional operations based on
isRunning
state. โ๏ธ - Strategic use of
createElement
,classList
, andappendChild
for dynamic content manipulation. ๐ ๏ธ