If you were in a wilderness area and crossing a stream/river with a waterfall downstream of the crossing and there were no signs, how far above the waterfall should you cross?
The correct answer is as far upstream as you need to in order to swim/wade/jump across the stream and still provide the margin for error you are comfortable.
The problem answering the question in a more straight forward manner you have waterfalls like victoria falls (pictured below) that would almost certainly result in a fatal fall if you were to go over, but the chance of flushing over even when on the edge of the waterfall are low because of the depth and flow at the lip.
To Contrast here is huka falls, a waterfall that even hundreds of meters upstream you cannot safely cross because of the heavy currents and lack of exit points from the river.
In general you should avoid any water crossing with any meaningful current; unless you have whitewater experience or you can maintain your footing, shin deep or less, the entire time.
In an emergency type scenario ropes can be helpful to mitigate risks, but require careful application as they add complexity to a potentially dangerous situation. Again experience goes a long way.
Edit: I should probably add the Victoria falls is not actually travesable all the way across the lip, but was used as an extreme example of getting close to a lip of a waterfall in one location.
Source: I'm a whitewater enthusiast who has willingly gone over numerous waterfalls and navigated safely around even more using a variety of watercraft, swimming, wading etc.
There are too many factors to consider to give anything like a precise answer.
I suggest a conservative rule of thumb for an average hiker, not a super athlete: if you can see or hear the waterfall and you cannot step or jump over the stream in one step or jump, you are too close.
If the waterfall is tiny, and/or the stream is shallow and slow, and/or there are some flat rocks in the stream this rule is too conservative.
Like everything else in TGO, the answer depends on judgement and the amount of risk a person is willing to take.
On pure math
ws = water speed
wd = width
ss = swimmer speed
us = how far upstream
us = wd * ws / ss
In reality the moving water will inhibit swimming speed compared to still water. Double that length might not be good enough.
If the water speed is slower than your swimming speed could angle upstream and swim straight across. But you rarely find slow water upstream from a water fall.
An average human can swim about 250 feet per minute. Throw a stick in the middle and measure how far it goes in a minute.